Commits

Philip Jenvey  committed 2664c3c

2to3, fix fix fix

  • Participants
  • Parent commits 3b672ce
  • Branches py3k

Comments (0)

Files changed (2)

File pypy/interpreter/app_main.py

     executable = sys.pypy_find_executable(executable)
     stdlib_path = sys.pypy_find_stdlib(executable)
     if stdlib_path is None:
-        print >> sys.stderr, STDLIB_WARNING
+        print(STDLIB_WARNING, file=sys.stderr)
     else:
         sys.path[:] = stdlib_path
     # from this point on, we are free to use all the unicode stuff we want,

File pypy/interpreter/test2/test_app_main.py

     def test_sysflags(self):
         flags = (
             ("debug", "-d", "1"),
-            ("py3k_warning", "-3", "1"),
             ("division_warning", "-Qwarn", "1"),
             ("division_warning", "-Qwarnall", "2"),
             ("division_new", "-Qnew", "1"),
                        run_command='pass', **expected)
 
     def test_sysflags_envvar(self, monkeypatch):
-        monkeypatch.setenv('PYTHONNOUSERSITE', '1')
         expected = {"no_user_site": True}
-        self.check(['-c', 'pass'], {}, sys_argv=['-c'], run_command='pass', **expected)
+        self.check(['-c', 'pass'], {'PYTHONNOUSERSITE': '1'}, sys_argv=['-c'],
+                   run_command='pass', **expected)
 
 
 class TestInteraction:
         child.logfile = sys.stdout
         return child
 
-    def spawn(self, argv):
+    def spawn(self, argv, env=None):
         # make sure that when we do 'import pypy' we get the correct package
         with setpythonpath():
-            return self._spawn(python3, [app_main] + argv)
+            return self._spawn(python3, [app_main] + argv, env=env)
 
     def test_interactive(self):
         child = self.spawn([])
         child.expect(re.escape(repr('NameError')))
 
     def test_atexit(self):
+        skip("Python3 atexit is a builtin module")
         child = self.spawn([])
         child.expect('>>> ')
         child.sendline('def f(): print("foobye")')
         child.expect('Traceback')
         child.expect('NameError')
 
-    def test_pythonstartup_file1(self, monkeypatch):
+    def test_pythonstartup_file1(self, monkeypatch, demo_script):
         monkeypatch.setenv('PYTHONPATH', None)
         monkeypatch.setenv('PYTHONSTARTUP', demo_script)
         child = self.spawn([])
         child.expect('Traceback')
         child.expect('NameError')
 
-    def test_pythonstartup_file2(self, monkeypatch):
+    def test_pythonstartup_file2(self, monkeypatch, crashing_demo_script):
         monkeypatch.setenv('PYTHONPATH', None)
         monkeypatch.setenv('PYTHONSTARTUP', crashing_demo_script)
         child = self.spawn([])
     def test_python_path_keeps_duplicates(self):
         old = os.environ.get('PYTHONPATH', '')
         try:
-            os.environ['PYTHONPATH'] = 'foobarbaz:foobarbaz'
-            child = self.spawn(['-c', 'import sys; print sys.path'])
+            child = self.spawn(['-c', 'import sys; print(sys.path)'],
+                               env={'PYTHONPATH': 'foobarbaz:foobarbaz'})
             child.expect(r"\['', 'foobarbaz', 'foobarbaz', ")
         finally:
             os.environ['PYTHONPATH'] = old
         old = os.environ.get('PYTHONPATH', '')
         try:
             os.environ['PYTHONPATH'] = 'foobarbaz'
-            child = self.spawn(['-E', '-c', 'import sys; print sys.path'])
+            child = self.spawn(['-E', '-c', 'import sys; print(sys.path)'])
             from pexpect import EOF
             index = child.expect(['foobarbaz', EOF])
             assert index == 1      # no foobarbaz
         print 'POPEN:', cmdline
         child_in, child_out_err = os.popen4(cmdline)
         data = child_out_err.read(11)
-        assert data == '\x00[STDERR]\n\x00'    # from stderr
+        # Py3 is always at least line buffered
+        assert data == '\x00(STDOUT)\n\x00'    # from stdout
         child_in.close()
         data = child_out_err.read(11)
-        assert data == '\x00(STDOUT)\n\x00'    # from stdout
+        assert data == '\x00[STDERR]\n\x00'    # from stderr
         child_out_err.close()
 
     def test_non_interactive_stdout_unbuffered(self, monkeypatch):
             time.sleep(1)
             # stdout flushed automatically here
             """)
-        cmdline = '%s -E "%s" %s' % (sys.executable, app_main, path)
+        cmdline = '%s -E "%s" %s' % (python3, app_main, path)
         print 'POPEN:', cmdline
         child_in, child_out_err = os.popen4(cmdline)
         data = child_out_err.read(11)