1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 92546f4

Issue #1514
A test for reimporting built-in modules (as opposed to reloading them).

  • Participants
  • Parent commits 35e9a41
  • Branches default

Comments (0)

Files changed (1)

File pypy/module/imp/test/test_import.py

View file
  • Ignore whitespace
         assert sys.path is oldpath
         assert 'setdefaultencoding' in dir(sys)
 
+    def test_reimport_builtin(self):
+        # ...but not reload()!
+        import sys
+        oldpath = sys.path
+        sys.setdefaultencoding = "<test_reimport_builtin removed this>"
+
+        del sys.modules['sys']
+        import sys as sys1
+        assert sys.modules['sys'] is sys1 is sys
+
+        assert sys.path is oldpath
+        assert sys.setdefaultencoding == "<test_reimport_builtin removed this>"
+
+        reload(sys)   # fix it for people that want 'setdefaultencoding'
+        assert sys.setdefaultencoding != "<test_reimport_builtin removed this>"
+
     def test_reload_infinite(self):
         import infinite_reload