(self)
| 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 | |
| 304 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected