def test_known_bound_method_as_part_of_class(self): class OtherObject(object): def a_method(self): pass class_name_and_loc = locations.get_name_and_loc(OtherObject().a_method) self.assertIn('OtherObject.a_method', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_known(self): class OtherObject(object): pass class_name_and_loc = locations.get_name_and_loc(OtherObject) self.assertIn('OtherObject', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_known_as_part_of_class(self): class OtherObject(object): def a_method(self): pass class_name_and_loc = locations.get_name_and_loc(OtherObject.a_method) self.assertIn('OtherObject.a_method', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_unknown(self): unknown_class = type('UnknownClass', (object,), {}) class_name_and_loc = locations.get_name_and_loc(unknown_class) self.assertEqual('tests.locations_test.UnknownClass', class_name_and_loc)
def test_known_external_bound_method_as_part_of_class(self): class_name_and_loc = locations.get_name_and_loc(ExternalObject().a_method) self.assertIn('ExternalObject.a_method', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_known_external(self): class_name_and_loc = locations.get_name_and_loc(ExternalObject) self.assertIn('ExternalObject', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_unknown(self): unknown_class = type('UnknownClass', (object, ), {}) class_name_and_loc = locations.get_name_and_loc(unknown_class) self.assertEqual('tests.locations_test.UnknownClass', class_name_and_loc)
def test_known_external_bound_method_as_part_of_class(self): class_name_and_loc = locations.get_name_and_loc( ExternalObject().a_method) self.assertIn('ExternalObject.a_method', class_name_and_loc) self.assertIn('locations_test.py', class_name_and_loc)
def test_unknown(self): self.assertEqual('unittest.case.TestCase', locations.get_name_and_loc(unittest.TestCase))