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

Method test__get_version

Lib/test/test_pydoc/test_pydoc.py:2373–2397  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2371 self.assertIsNone(self._get_revised_path(trailing_argv0dir))
2372
2373 def test__get_version(self):
2374 import json
2375 import warnings
2376
2377 class MyModule:
2378 __name__ = 'my_module'
2379
2380 @property
2381 def __version__(self):
2382 warnings._deprecated("__version__", remove=(3, 20))
2383 return "1.2.3"
2384
2385 module = MyModule()
2386 doc = pydoc.Doc()
2387 with warnings.catch_warnings(record=True) as w: # TODO: remove in 3.20
2388 warnings.simplefilter("always")
2389 version = doc._get_version(json)
2390 self.assertEqual(version, "2.0.9")
2391 self.assertEqual(len(w), 0)
2392
2393 with warnings.catch_warnings(record=True) as w:
2394 warnings.simplefilter("always")
2395 version = doc._get_version(module)
2396 self.assertEqual(version, "1.2.3")
2397 self.assertEqual(len(w), 1)
2398
2399
2400def setUpModule():

Callers

nothing calls this directly

Calls 3

_get_versionMethod · 0.95
MyModuleClass · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected