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

Side by Side Diff: Lib/test/test_importlib/test_api.py

Issue 19413: Reload semantics changed unexpectedly in Python 3.3
Patch Set: Created 6 years, 3 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/importlib/__init__.py ('k') | Python/importlib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from . import util 1 from . import util
2 2
3 frozen_init, source_init = util.import_importlib('importlib') 3 frozen_init, source_init = util.import_importlib('importlib')
4 frozen_machinery, source_machinery = util.import_importlib('importlib.machinery' ) 4 frozen_machinery, source_machinery = util.import_importlib('importlib.machinery' )
5 5
6 import sys 6 import sys
7 from test import support 7 from test import support
8 import types 8 import types
9 import unittest 9 import unittest
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 sys.modules['top_level'] = module 182 sys.modules['top_level'] = module
183 mock = util.mock_modules('top_level', 183 mock = util.mock_modules('top_level',
184 module_code={'top_level': code}) 184 module_code={'top_level': code})
185 with mock: 185 with mock:
186 with util.import_state(meta_path=[mock]): 186 with util.import_state(meta_path=[mock]):
187 module = self.init.import_module('top_level') 187 module = self.init.import_module('top_level')
188 reloaded = self.init.reload(module) 188 reloaded = self.init.reload(module)
189 actual = sys.modules['top_level'] 189 actual = sys.modules['top_level']
190 self.assertEqual(actual.spam, 3) 190 self.assertEqual(actual.spam, 3)
191 self.assertEqual(reloaded.spam, 3) 191 self.assertEqual(reloaded.spam, 3)
192
193 def test_reload_missing_loader(self):
194 with support.CleanImport('types'):
195 import types
196 del types.__loader__
197 reloaded = self.init.reload(types)
198
199 self.assertIs(reloaded, types)
200 self.assertIs(sys.modules['types'], types)
201
192 202
193 class Frozen_ReloadTests(ReloadTests, unittest.TestCase): 203 class Frozen_ReloadTests(ReloadTests, unittest.TestCase):
194 init = frozen_init 204 init = frozen_init
195 205
196 class Source_ReloadTests(ReloadTests, unittest.TestCase): 206 class Source_ReloadTests(ReloadTests, unittest.TestCase):
197 init = source_init 207 init = source_init
198 208
199 209
200 class InvalidateCacheTests: 210 class InvalidateCacheTests:
201 211
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 270
261 class Frozen_StartupTests(StartupTests, unittest.TestCase): 271 class Frozen_StartupTests(StartupTests, unittest.TestCase):
262 machinery = frozen_machinery 272 machinery = frozen_machinery
263 273
264 class Source_StartupTests(StartupTests, unittest.TestCase): 274 class Source_StartupTests(StartupTests, unittest.TestCase):
265 machinery = source_machinery 275 machinery = source_machinery
266 276
267 277
268 if __name__ == '__main__': 278 if __name__ == '__main__':
269 unittest.main() 279 unittest.main()
OLDNEW
« no previous file with comments | « Lib/importlib/__init__.py ('k') | Python/importlib.h » ('j') | no next file with comments »

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