MCPcopy Index your code
hub / github.com/python/cpython / test_7

Method test_7

Lib/test/test_pkg.py:237–278  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

235 self.run_code(s)
236
237 def test_7(self):
238 hier = [
239 ("t7.py", ""),
240 ("t7", None),
241 ("t7 __init__.py", ""),
242 ("t7 sub.py",
243 "raise RuntimeError('Shouldnt load sub.py')"),
244 ("t7 sub", None),
245 ("t7 sub __init__.py", ""),
246 ("t7 sub .py",
247 "raise RuntimeError('Shouldnt load subsub.py')"),
248 ("t7 sub subsub", None),
249 ("t7 sub subsub __init__.py",
250 "spam = 1"),
251 ]
252 self.mkhier(hier)
253
254
255 t7, sub, subsub = None, None, None
256 import t7 as tas
257 self.assertEqual(fixdir(dir(tas)),
258 ['__doc__', '__file__', '__loader__', '__name__',
259 '__package__', '__path__', '__spec__'])
260 self.assertFalse(t7)
261 from t7 import sub as subpar
262 self.assertEqual(fixdir(dir(subpar)),
263 ['__doc__', '__file__', '__loader__', '__name__',
264 '__package__', '__path__', '__spec__'])
265 self.assertFalse(t7)
266 self.assertFalse(sub)
267 from t7.sub import subsub as subsubsub
268 self.assertEqual(fixdir(dir(subsubsub)),
269 ['__doc__', '__file__', '__loader__', '__name__',
270 '__package__', '__path__', '__spec__', 'spam'])
271 self.assertFalse(t7)
272 self.assertFalse(sub)
273 self.assertFalse(subsub)
274 from t7.sub.subsub import spam as ham
275 self.assertEqual(ham, 1)
276 self.assertFalse(t7)
277 self.assertFalse(sub)
278 self.assertFalse(subsub)
279
280 @unittest.skipIf(sys.flags.optimize >= 2,
281 "Docstrings are omitted with -O2 and above")

Callers

nothing calls this directly

Calls 4

mkhierMethod · 0.95
fixdirFunction · 0.85
assertFalseMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected