def check(self, argv, env, **expected): import StringIO from pypy.interpreter import app_main saved_env = os.environ.copy() saved_sys_argv = sys.argv[:] saved_sys_stdout = sys.stdout saved_sys_stderr = sys.stdout app_main.WE_ARE_TRANSLATED = False app_main.os = os try: os.environ.update(env) sys.stdout = sys.stderr = StringIO.StringIO() try: options = app_main.parse_command_line(argv) except SystemExit: output = expected['output_contains'] assert output in sys.stdout.getvalue() else: self.check_options(options, **expected) finally: os.environ.clear() os.environ.update(saved_env) sys.argv[:] = saved_sys_argv sys.stdout = saved_sys_stdout sys.stderr = saved_sys_stderr if __pypy__: __pypy__.set_debug(True) app_main.WE_ARE_TRANSLATED = True
def check(self, argv, env, **expected): import StringIO from pypy.interpreter import app_main saved_env = os.environ.copy() saved_sys_argv = sys.argv[:] saved_sys_stdout = sys.stdout saved_sys_stderr = sys.stdout app_main.os = os try: os.environ.update(env) sys.stdout = sys.stderr = StringIO.StringIO() try: options = app_main.parse_command_line(argv) except SystemExit: output = expected["output_contains"] assert output in sys.stdout.getvalue() else: self.check_options(options, **expected) finally: os.environ.clear() os.environ.update(saved_env) sys.argv[:] = saved_sys_argv sys.stdout = saved_sys_stdout sys.stderr = saved_sys_stderr