Beispiel #1
0
 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
Beispiel #2
0
    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