def test_valid_new_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) orig_module = sys.modules['ptvsd.untangle'] expected_module = ANY.dict_with({ 'id': ANY.int, 'name': orig_module.__name__, 'package': orig_module.__package__, 'path': orig_module.__file__, 'version': orig_module.__version__, }) assert expected_module == mgr.add_or_get_from_path( ptvsd.untangle.__file__) assert 1 == len(sink.event_data) assert [expected_module] == mgr.get_all() assert sink.event_data == [ { 'event': 'module', 'args': { 'reason': 'new', 'module': expected_module, }, }, ]
def test_valid_new_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) orig_module = sys.modules['ptvsd.untangle'] expected_module = { 'id': 1, 'name': orig_module.__name__, 'package': orig_module.__package__, 'path': orig_module.__file__, 'version': orig_module.__version__, } self.assertEqual(expected_module, mgr.add_or_get_from_path(ptvsd.untangle.__file__)) self.assertEqual(1, len(sink.event_data)) self.assertEqual([expected_module], mgr.get_all()) self.assertEqual([ { 'event': 'module', 'args': { 'reason': 'new', 'module': expected_module, }, }, ], sink.event_data)
def test_get_only_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) expected_module = ANY.dict_with({ 'id': 1, 'name': 'abc.xyz', 'package': 'abc', 'path': '/abc/xyz.py', 'version': '1.2.3.4a1', }) mgr.path_to_module_id['/abc/xyz.py'] = 1 mgr.module_id_to_details[1] = expected_module assert expected_module == mgr.add_or_get_from_path('/abc/xyz.py') assert 0 == len(sink.event_data) assert [expected_module] == mgr.get_all()
def test_get_only_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) expected_module = { 'id': 1, 'name': 'abc.xyz', 'package': 'abc', 'path': '/abc/xyz.py', 'version': '1.2.3.4a1', } mgr.path_to_module_id['/abc/xyz.py'] = 1 mgr.module_id_to_details[1] = expected_module self.assertEqual(expected_module, mgr.add_or_get_from_path('/abc/xyz.py')) self.assertEqual(0, len(sink.event_data)) self.assertEqual([expected_module], mgr.get_all())
def test_invalid_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) assert mgr.add_or_get_from_path('abc.py') is None assert 0 == len(sink.event_data) assert [] == mgr.get_all()
def test_invalid_module(self): sink = ModulesEventSink() mgr = ModulesManager(sink) self.assertEqual(None, mgr.add_or_get_from_path('abc.py')) self.assertEqual(0, len(sink.event_data)) self.assertEqual([], mgr.get_all())