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

Side by Side Diff: Lib/importlib/test/source/test_finder.py

Issue 842043: PEP 3147 implementation (Closed) Base URL: http://svn.python.org/view/*checkout*/python/branches/py3k/
Patch Set: Created 14 years 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
OLDNEW
1 from importlib import _bootstrap 1 from importlib import _bootstrap
2 from .. import abc 2 from .. import abc
3 from . import util as source_util 3 from . import util as source_util
4 from test.support import make_legacy_pyc
4 import os 5 import os
6 import errno
5 import py_compile 7 import py_compile
6 import unittest 8 import unittest
7 import warnings 9 import warnings
8 10
9 11
10 class FinderTests(abc.FinderTests): 12 class FinderTests(abc.FinderTests):
11 13
12 """For a top-level module, it should just be found directly in the 14 """For a top-level module, it should just be found directly in the
13 directory being searched. This is true for a directory with source 15 directory being searched. This is true for a directory with source
14 [top-level source], bytecode [top-level bc], or both [top-level both]. 16 [top-level source], bytecode [top-level bc], or both [top-level both].
(...skipping 30 matching lines...) Expand all
45 """ 47 """
46 if create is None: 48 if create is None:
47 create = {test} 49 create = {test}
48 with source_util.create_modules(*create) as mapping: 50 with source_util.create_modules(*create) as mapping:
49 if compile_: 51 if compile_:
50 for name in compile_: 52 for name in compile_:
51 py_compile.compile(mapping[name]) 53 py_compile.compile(mapping[name])
52 if unlink: 54 if unlink:
53 for name in unlink: 55 for name in unlink:
54 os.unlink(mapping[name]) 56 os.unlink(mapping[name])
57 try:
58 make_legacy_pyc(mapping[name])
59 except OSError as error:
60 if error.errno != errno.ENOENT:
Antoine Pitrou 2010/04/04 15:55:30 You should comment why it's ok to fail with ENOENT
barry 2010/04/06 23:05:09 When a test doesn't set compile_=True, there will
61 raise
55 loader = self.import_(mapping['.root'], test) 62 loader = self.import_(mapping['.root'], test)
56 self.assertTrue(hasattr(loader, 'load_module')) 63 self.assertTrue(hasattr(loader, 'load_module'))
57 return loader 64 return loader
58 65
59 def test_module(self): 66 def test_module(self):
60 # [top-level source] 67 # [top-level source]
61 self.run_test('top_level') 68 self.run_test('top_level')
62 # [top-level bc] 69 # [top-level bc]
63 self.run_test('top_level', compile_={'top_level'}, unlink={'top_level'}) 70 self.run_test('top_level', compile_={'top_level'},
71 unlink={'top_level'})
64 # [top-level both] 72 # [top-level both]
65 self.run_test('top_level', compile_={'top_level'}) 73 self.run_test('top_level', compile_={'top_level'})
66 74
67 # [top-level package] 75 # [top-level package]
68 def test_package(self): 76 def test_package(self):
69 # Source. 77 # Source.
70 self.run_test('pkg', {'pkg.__init__'}) 78 self.run_test('pkg', {'pkg.__init__'})
71 # Bytecode. 79 # Bytecode.
72 self.run_test('pkg', {'pkg.__init__'}, compile_={'pkg.__init__'}, 80 self.run_test('pkg', {'pkg.__init__'}, compile_={'pkg.__init__'},
73 unlink={'pkg.__init__'}) 81 unlink={'pkg.__init__'})
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 self.run_test('pkg', {'pkg.__init__'}, unlink={'pkg.__init__'}) 129 self.run_test('pkg', {'pkg.__init__'}, unlink={'pkg.__init__'})
122 130
123 131
124 def test_main(): 132 def test_main():
125 from test.support import run_unittest 133 from test.support import run_unittest
126 run_unittest(FinderTests) 134 run_unittest(FinderTests)
127 135
128 136
129 if __name__ == '__main__': 137 if __name__ == '__main__':
130 test_main() 138 test_main()
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b