def test_issues_warning_for_missing_method(self): with warnings.catch_warnings(record = True) as w: warnings.simplefilter("always") _get_traceable_method_names(["inherited"], SampleClass) self.assertEqual(1, len(w)) self.assertEqual( "'inherited' does not identify a method defined in SampleClass", str(w[0].message))
def test_issues_warning_for_missing_method(self): with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") _get_traceable_method_names(["inherited"], SampleClass) self.assertEqual(1, len(w)) self.assertEqual( "'inherited' does not identify a method defined in SampleClass", str(w[0].message))
def test_identifies_named_methods_defined_in_class(self): actual_method_names = _get_traceable_method_names( [ "class_method", "static_method", "__init__", "public", "overridden", "_nonpublic", "__internal", "__eq__" ], SampleClass) self.assertEqual( sorted([ "class_method", "static_method", "__init__", "public", "overridden", "_nonpublic", "_SampleClass__internal", "__eq__", ]), sorted(actual_method_names))
def test_can_exclude_instead_of_include_named_methods(self): actual_method_names = _get_traceable_method_names( [ "overridden", "_nonpublic", ], SampleClass, exclude=True) self.assertEqual( sorted([ "class_method", "static_method", "__init__", "public", "_SampleClass__internal", ]), sorted(actual_method_names))
def test_issues_warning_when_exclude_resolves_to_empty_list(self): with warnings.catch_warnings(record = True) as w: warnings.simplefilter("always") actual_method_names = _get_traceable_method_names( [ "class_method", "static_method", "__init__", "public", "overridden", "_nonpublic", "__internal", ], SampleClass, exclude=True) self.assertEqual([], actual_method_names) self.assertEqual(1, len(w)) self.assertEqual( "exclude=True with the supplied method names results in NO " "traceable methods for SampleClass", str(w[0].message))
def test_mangles_internal_names(self): actual_method_names = _get_traceable_method_names(["__internal"], SampleClass) self.assertEqual(["_SampleClass__internal"], actual_method_names)
def test_mangles_internal_names(self): actual_method_names = _get_traceable_method_names([ "__internal"], SampleClass) self.assertEqual([ "_SampleClass__internal"], actual_method_names)