Ejemplo n.º 1
0
 def test_runscript(self):
     script = os.path.join(self.instancedir, 'test_script.py')
     # Use a backslash to fake windows paths under linux
     bar = r'\bar'
     with open(script, 'w') as scriptfile:
         scriptfile.write(test_script)
     try:
         from Zope2.utilities.zconsole import runscript
         sys.argv = [
             sys.executable,
             'run',
             self.zopeconf,
             script,
             bar, 'baz']
         sys.stdout = StringIO()
         runscript(self.zopeconf, script, 'bar', 'baz')
         sys.stdout.seek(0)
         got = sys.stdout.read()
     finally:
         sys.argv = self.stored_sys_argv
         sys.stdout = self.stored_stdout
     # We get double escape for backslash \ on windows from test script,
     # so we have the raw string in there.
     expected = (
         "42\n"
         r"['run', {!r}, {!r}, {!r}, 'baz']"
         "\nPropertyManager\n".format(self.zopeconf, script, bar))
     self.assertEqual(expected, got)
Ejemplo n.º 2
0
 def test_runscript(self):
     script = os.path.join(self.instancedir, 'test_script.py')
     with open(script, 'w') as scriptfile:
         scriptfile.write(test_script)
     try:
         from Zope2.utilities.zconsole import runscript
         sys.argv = [
             sys.executable, 'run', self.zopeconf, script, 'bar', 'baz'
         ]
         sys.stdout = StringIO()
         runscript(self.zopeconf, script, 'bar', 'baz')
         sys.stdout.seek(0)
         got = sys.stdout.read()
     finally:
         sys.argv = self.stored_sys_argv
         sys.stdout = self.stored_stdout
     expected = "42\n['run', '{}', '{}', 'bar', 'baz']\n".format(
         self.zopeconf, script)  # noqa: E501
     self.assertEqual(expected, got)
Ejemplo n.º 3
0
 def test_runscript(self):
     script = os.path.join(self.instancedir, 'test_script.py')
     # Use a backslash to fake windows paths under linux
     bar = r'\bar'
     with open(script, 'w') as scriptfile:
         scriptfile.write(test_script)
     try:
         from Zope2.utilities.zconsole import runscript
         sys.argv = [
             sys.executable, 'run', self.zopeconf, script, bar, 'baz'
         ]
         sys.stdout = StringIO()
         runscript(self.zopeconf, script, 'bar', 'baz')
         sys.stdout.seek(0)
         got = sys.stdout.read()
     finally:
         sys.argv = self.stored_sys_argv
         sys.stdout = self.stored_stdout
     # We get double escape for backslash \ on windows from test script,
     # so we have the raw string in there.
     expected = ("42\n"
                 r"['run', {!r}, {!r}, {!r}, 'baz']"
                 "\nPropertyManager\n".format(self.zopeconf, script, bar))
     self.assertEqual(expected, got)