abc fixes.

This commit is contained in:
Barry Warsaw 2012-07-31 17:52:32 -04:00
parent 38f75cbc00
commit 0efcf99c9e
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,9 @@ class SourceOnlyLoaderMock(abc.SourceLoader):
def get_filename(self, fullname): def get_filename(self, fullname):
return self.path return self.path
def module_repr(self, module):
return '<module>'
class SourceLoaderMock(SourceOnlyLoaderMock): class SourceLoaderMock(SourceOnlyLoaderMock):
@ -107,6 +110,9 @@ class PyLoaderMock(abc.PyLoader):
assert issubclass(w[0].category, DeprecationWarning) assert issubclass(w[0].category, DeprecationWarning)
return path return path
def module_repr(self):
return '<module>'
class PyLoaderCompatMock(PyLoaderMock): class PyLoaderCompatMock(PyLoaderMock):
@ -779,11 +785,16 @@ class AbstractMethodImplTests(unittest.TestCase):
class Loader(abc.Loader): class Loader(abc.Loader):
def load_module(self, fullname): def load_module(self, fullname):
super().load_module(fullname) super().load_module(fullname)
def module_repr(self, module):
super().module_repr(module)
class Finder(abc.Finder): class Finder(abc.Finder):
def find_module(self, _): def find_module(self, _):
super().find_module(_) super().find_module(_)
def find_loader(self, _):
super().find_loader(_)
class ResourceLoader(Loader, abc.ResourceLoader): class ResourceLoader(Loader, abc.ResourceLoader):
def get_data(self, _): def get_data(self, _):
super().get_data(_) super().get_data(_)

View File

@ -29,6 +29,7 @@ class SimpleTest(unittest.TestCase):
# If fullname is not specified that assume self.name is desired. # If fullname is not specified that assume self.name is desired.
class TesterMixin(importlib.abc.Loader): class TesterMixin(importlib.abc.Loader):
def load_module(self, fullname): return fullname def load_module(self, fullname): return fullname
def module_repr(self, module): return '<module>'
class Tester(importlib.abc.FileLoader, TesterMixin): class Tester(importlib.abc.FileLoader, TesterMixin):
def get_code(self, _): pass def get_code(self, _): pass
@ -49,6 +50,7 @@ class SimpleTest(unittest.TestCase):
def get_code(self, _): pass def get_code(self, _): pass
def get_source(self, _): pass def get_source(self, _): pass
def is_package(self, _): pass def is_package(self, _): pass
def module_repr(self, _): pass
path = 'some_path' path = 'some_path'
name = 'some_name' name = 'some_name'