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

Method test_invalidate_caches

Lib/test/test_platform.py:89–119  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

87 platform._os_release_cache = None
88
89 def test_invalidate_caches(self):
90 self.clear_caches()
91
92 self.assertDictEqual(platform._platform_cache, {})
93 self.assertDictEqual(platform._sys_version_cache, {})
94 self.assertIsNone(platform._uname_cache)
95 self.assertIsNone(platform._os_release_cache)
96
97 # fill the cached entries (some have side effects on others)
98 platform.platform() # for platform._platform_cache
99 platform.python_implementation() # for platform._sys_version_cache
100 platform.uname() # for platform._uname_cache
101
102 # check that the cache are filled
103 self.assertNotEqual(platform._platform_cache, {})
104 self.assertNotEqual(platform._sys_version_cache, {})
105 self.assertIsNotNone(platform._uname_cache)
106
107 try:
108 platform.freedesktop_os_release()
109 except OSError:
110 self.assertIsNone(platform._os_release_cache)
111 else:
112 self.assertIsNotNone(platform._os_release_cache)
113
114 with self.subTest('clear platform caches'):
115 platform.invalidate_caches()
116 self.assertDictEqual(platform._platform_cache, {})
117 self.assertDictEqual(platform._sys_version_cache, {})
118 self.assertIsNone(platform._uname_cache)
119 self.assertIsNone(platform._os_release_cache)
120
121 def test_architecture(self):
122 res = platform.architecture()

Callers

nothing calls this directly

Calls 7

clear_cachesMethod · 0.95
assertDictEqualMethod · 0.80
assertIsNoneMethod · 0.80
assertNotEqualMethod · 0.80
assertIsNotNoneMethod · 0.80
subTestMethod · 0.45
invalidate_cachesMethod · 0.45

Tested by

no test coverage detected