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

Method test_get_entity

Lib/idlelib/idle_test/test_autocomplete.py:280–301  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

278 self.assertEqual(b, ['.hidden', 'monty', 'python'])
279
280 def test_get_entity(self):
281 # Test that a name is in the namespace of sys.modules and
282 # __main__.__dict__.
283 acp = self.autocomplete
284 Equal = self.assertEqual
285
286 Equal(acp.get_entity('int'), int)
287
288 # Test name from sys.modules.
289 mock = Mock()
290 with patch.dict('sys.modules', {'tempfile': mock}):
291 Equal(acp.get_entity('tempfile'), mock)
292
293 # Test name from __main__.__dict__.
294 di = {'foo': 10, 'bar': 20}
295 with patch.dict('__main__.__dict__', {'d': di}):
296 Equal(acp.get_entity('d'), di)
297
298 # Test name not in namespace.
299 with patch.dict('__main__.__dict__', {}):
300 with self.assertRaises(NameError):
301 acp.get_entity('not_exist')
302
303
304if __name__ == '__main__':

Callers

nothing calls this directly

Calls 3

MockClass · 0.90
get_entityMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected