Skip to content

Commit

Permalink
Removed Python 3.2 workaround in GeneralTests.
Browse files Browse the repository at this point in the history
  • Loading branch information
benkonrath committed Jun 30, 2017
1 parent 3cb3694 commit 961fd7d
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,8 @@

class GeneralTests(TestCase):

@classmethod
def _find_subclasses_for_package_py32(cls, base_class, package):
classes = []
for attr in dir(localflavor):
if attr.startswith('_'):
continue
sub_module = importlib.import_module(package.__name__ + '.' + attr)
sub_module_fields = cls._find_subclasses_for_package(base_class, sub_module)
if len(sub_module_fields) > 0:
classes.extend(sub_module_fields)

return classes

@classmethod
def _find_subclasses_for_package(cls, base_class, package):
# Finding the localflavor model classes directly with walk_packages doesn't work with Python 3.2. The workaround
# is to find the classes in all of the submodules.
if sys.version_info[:2] == (3, 2):
return cls._find_subclasses_for_package_py32(base_class, package)

@staticmethod
def _find_subclasses_for_package(base_class, package):
classes = []
for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__ + '.',
onerror=lambda x: None):
Expand Down

0 comments on commit 961fd7d

Please sign in to comment.