Jelajahi Sumber

Update 300_import.py

blueloveTH 1 bulan lalu
induk
melakukan
a1bfebd30c
1 mengubah file dengan 14 tambahan dan 4 penghapusan
  1. 14 4
      tests/300_import.py

+ 14 - 4
tests/300_import.py

@@ -3,7 +3,14 @@ try:
 except ImportError:
     exit(0)
 
-os.chdir('tests')
+import sys
+is_pyc = sys.argv[0].endswith('.pyc')
+
+if is_pyc:
+    os.chdir('tmp/tests')
+else:
+    os.chdir('tests')
+
 assert os.getcwd().endswith('tests')
 
 import test1
@@ -49,8 +56,11 @@ from math import (
     cos
 )
 
+assert __import__('math').pi > 3
+
 # test reload (dummy)
-import importlib
-importlib.reload(test2.a)
+if not is_pyc:
+    import importlib
+    importlib.reload(test2.a)
 
-assert __import__('math').pi > 3
+