summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-01 19:08:42 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-11-01 19:08:42 (GMT)
commit9033339673b0b1867cb2135767c0d70613d70ee1 (patch)
tree65b03cc554498c91faa28627de174fc5a9f0d30d /Lib/test/test_import.py
parente02647a66953bad1987daf696dc28e0dd5b2daa9 (diff)
downloadcpython-9033339673b0b1867cb2135767c0d70613d70ee1.zip
cpython-9033339673b0b1867cb2135767c0d70613d70ee1.tar.gz
cpython-9033339673b0b1867cb2135767c0d70613d70ee1.tar.bz2
Fixed unit tests for os.environ. Some of the tests didn't test at all because os.environ was empty.
Added import test for sys.path entries with non ASCII characters. The tests are passing on my Ubuntu box with utf-8 locales but they aren't passing on Windows XP.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r--Lib/test/test_import.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 3203904..7bb122d 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -3,10 +3,11 @@ from test.test_support import TESTFN, run_unittest, catch_warning
import unittest
import os
import random
+import shutil
import sys
import py_compile
import warnings
-from test.test_support import unlink
+from test.test_support import unlink, TESTFN, unload
def remove_files(name):
@@ -157,8 +158,37 @@ class ImportTest(unittest.TestCase):
warnings.simplefilter('error', ImportWarning)
self.assertRaises(ImportWarning, __import__, "site-packages")
+class UnicodePathsTests(unittest.TestCase):
+ SAMPLES = ('test', 'testäöüß', 'testéè', 'test°³²')
+ path = TESTFN
+
+ def setUp(self):
+ os.mkdir(self.path)
+ self.syspath = sys.path[:]
+
+ def tearDown(self):
+ shutil.rmtree(self.path)
+ sys.path = self.syspath
+
+ def test_sys_path(self):
+ for i, subpath in enumerate(self.SAMPLES):
+ path = os.path.join(self.path, subpath)
+ os.mkdir(path)
+ self.failUnless(os.path.exists(path), os.listdir(self.path))
+ f = open(os.path.join(path, 'testimport%i.py' % i), 'w')
+ f.write("testdata = 'unicode path %i'\n" % i)
+ f.close()
+ sys.path.append(path)
+ try:
+ mod = __import__("testimport%i" % i)
+ except ImportError:
+ print(path, file=sys.stderr)
+ raise
+ self.assertEqual(mod.testdata, 'unicode path %i' % i)
+ unload("testimport%i" % i)
+
def test_main(verbose=None):
- run_unittest(ImportTest)
+ run_unittest(ImportTest, UnicodePathsTests)
if __name__ == '__main__':
test_main()