Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Lib/test/test_pkgimport.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_os.py ('k') | Lib/test/test_platform.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import sys 2 import sys
3 import shutil 3 import shutil
4 import string 4 import string
5 import random 5 import random
6 import tempfile 6 import tempfile
7 import unittest 7 import unittest
8 8
9 from imp import cache_from_source 9 from imp import cache_from_source
10 from test.support import run_unittest, create_empty_file 10 from test.support import run_unittest
11 11
12 class TestImport(unittest.TestCase): 12 class TestImport(unittest.TestCase):
13 13
14 def __init__(self, *args, **kw): 14 def __init__(self, *args, **kw):
15 self.package_name = 'PACKAGE_' 15 self.package_name = 'PACKAGE_'
16 while self.package_name in sys.modules: 16 while self.package_name in sys.modules:
17 self.package_name += random.choose(string.ascii_letters) 17 self.package_name += random.choose(string.ascii_letters)
18 self.module_name = self.package_name + '.foo' 18 self.module_name = self.package_name + '.foo'
19 unittest.TestCase.__init__(self, *args, **kw) 19 unittest.TestCase.__init__(self, *args, **kw)
20 20
21 def remove_modules(self): 21 def remove_modules(self):
22 for module_name in (self.package_name, self.module_name): 22 for module_name in (self.package_name, self.module_name):
23 if module_name in sys.modules: 23 if module_name in sys.modules:
24 del sys.modules[module_name] 24 del sys.modules[module_name]
25 25
26 def setUp(self): 26 def setUp(self):
27 self.test_dir = tempfile.mkdtemp() 27 self.test_dir = tempfile.mkdtemp()
28 sys.path.append(self.test_dir) 28 sys.path.append(self.test_dir)
29 self.package_dir = os.path.join(self.test_dir, 29 self.package_dir = os.path.join(self.test_dir,
30 self.package_name) 30 self.package_name)
31 os.mkdir(self.package_dir) 31 os.mkdir(self.package_dir)
32 create_empty_file(os.path.join(self.package_dir, '__init__.py')) 32 open(os.path.join(self.package_dir, '__init__.py'), 'w').close()
33 self.module_path = os.path.join(self.package_dir, 'foo.py') 33 self.module_path = os.path.join(self.package_dir, 'foo.py')
34 34
35 def tearDown(self): 35 def tearDown(self):
36 shutil.rmtree(self.test_dir) 36 shutil.rmtree(self.test_dir)
37 self.assertNotEqual(sys.path.count(self.test_dir), 0) 37 self.assertNotEqual(sys.path.count(self.test_dir), 0)
38 sys.path.remove(self.test_dir) 38 sys.path.remove(self.test_dir)
39 self.remove_modules() 39 self.remove_modules()
40 40
41 def rewrite_file(self, contents): 41 def rewrite_file(self, contents):
42 compiled_path = cache_from_source(self.module_path) 42 compiled_path = cache_from_source(self.module_path)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 module = __import__(self.module_name).foo 75 module = __import__(self.module_name).foo
76 self.assertEqual(getattr(module, var), 1) 76 self.assertEqual(getattr(module, var), 1)
77 77
78 78
79 def test_main(): 79 def test_main():
80 run_unittest(TestImport) 80 run_unittest(TestImport)
81 81
82 82
83 if __name__ == "__main__": 83 if __name__ == "__main__":
84 test_main() 84 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_os.py ('k') | Lib/test/test_platform.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+