issue #477: disable Django parts of module_finder_test on 2.4.

issue510
David Wilson 6 years ago
parent b6634194af
commit 767331d76f

@ -162,35 +162,7 @@ class ResolveRelPathTest(testlib.TestCase):
self.assertEquals('', self.call('email.utils', 3)) self.assertEquals('', self.call('email.utils', 3))
class DjangoMixin(object): class FakeSshTest(testlib.TestCase):
WEBPROJECT_PATH = testlib.data_path('webproject')
# TODO: rip out Django and replace with a static tree of weird imports that
# don't depend on .. Django! The hack below is because the version of
# Django we need to test against 2.6 doesn't actually run on 3.6. But we
# don't care, we just need to be able to import it.
#
# File "django/utils/html_parser.py", line 12, in <module>
# AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
#
import pkg_resources._vendor.six
from django.utils.six.moves import html_parser as _html_parser
_html_parser.HTMLParseError = Exception
@classmethod
def setUpClass(cls):
super(DjangoMixin, cls).setUpClass()
sys.path.append(cls.WEBPROJECT_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = 'webproject.settings'
@classmethod
def tearDownClass(cls):
sys.path.remove(cls.WEBPROJECT_PATH)
del os.environ['DJANGO_SETTINGS_MODULE']
super(DjangoMixin, cls).tearDownClass()
class FindRelatedImportsTest(DjangoMixin, testlib.TestCase):
klass = mitogen.master.ModuleFinder klass = mitogen.master.ModuleFinder
def call(self, fullname): def call(self, fullname):
@ -206,42 +178,8 @@ class FindRelatedImportsTest(DjangoMixin, testlib.TestCase):
'mitogen.parent', 'mitogen.parent',
]) ])
def test_django_db(self):
import django.db
related = self.call('django.db')
self.assertEquals(related, [
'django',
'django.core',
'django.core.signals',
'django.db.utils',
'django.utils.functional',
])
def test_django_db_models(self):
import django.db.models
related = self.call('django.db.models')
self.maxDiff=None
self.assertEquals(related, [
u'django',
u'django.core.exceptions',
u'django.db',
u'django.db.models',
u'django.db.models.aggregates',
u'django.db.models.base',
u'django.db.models.deletion',
u'django.db.models.expressions',
u'django.db.models.fields',
u'django.db.models.fields.files',
u'django.db.models.fields.related',
u'django.db.models.fields.subclassing',
u'django.db.models.loading',
u'django.db.models.manager',
u'django.db.models.query',
u'django.db.models.signals',
])
class FindRelatedTest(testlib.TestCase):
class FindRelatedTest(DjangoMixin, testlib.TestCase):
klass = mitogen.master.ModuleFinder klass = mitogen.master.ModuleFinder
def call(self, fullname): def call(self, fullname):
@ -260,6 +198,8 @@ class FindRelatedTest(DjangoMixin, testlib.TestCase):
SIMPLE_EXPECT.add('mitogen.compat.functools') SIMPLE_EXPECT.add('mitogen.compat.functools')
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
SIMPLE_EXPECT.add('mitogen.compat.tokenize') SIMPLE_EXPECT.add('mitogen.compat.tokenize')
if sys.version_info < (2, 6):
SIMPLE_EXPECT.add('mitogen.compat.pkgutil')
def test_simple(self): def test_simple(self):
import mitogen.fakessh import mitogen.fakessh
@ -267,131 +207,203 @@ class FindRelatedTest(DjangoMixin, testlib.TestCase):
self.assertEquals(set(related), self.SIMPLE_EXPECT) self.assertEquals(set(related), self.SIMPLE_EXPECT)
class DjangoFindRelatedTest(DjangoMixin, testlib.TestCase): if sys.version_info > (2, 6):
klass = mitogen.master.ModuleFinder class DjangoMixin(object):
maxDiff = None WEBPROJECT_PATH = testlib.data_path('webproject')
def call(self, fullname): # TODO: rip out Django and replace with a static tree of weird imports
return self.klass().find_related(fullname) # that don't depend on .. Django! The hack below is because the version
# of Django we need to test against 2.6 doesn't actually run on 3.6.
def test_django_db(self): # But we don't care, we just need to be able to import it.
import django.db #
related = self.call('django.db') # File "django/utils/html_parser.py", line 12, in <module>
self.assertEquals(related, [ # AttributeError: module 'html.parser' has no attribute
u'django', # 'HTMLParseError'
u'django.conf', #
u'django.conf.global_settings', import pkg_resources._vendor.six
u'django.core', from django.utils.six.moves import html_parser as _html_parser
u'django.core.exceptions', _html_parser.HTMLParseError = Exception
u'django.core.signals',
u'django.db.utils', @classmethod
u'django.dispatch', def setUpClass(cls):
u'django.dispatch.dispatcher', super(DjangoMixin, cls).setUpClass()
u'django.dispatch.saferef', sys.path.append(cls.WEBPROJECT_PATH)
u'django.utils', os.environ['DJANGO_SETTINGS_MODULE'] = 'webproject.settings'
u'django.utils._os',
u'django.utils.encoding', @classmethod
u'django.utils.functional', def tearDownClass(cls):
u'django.utils.importlib', sys.path.remove(cls.WEBPROJECT_PATH)
u'django.utils.module_loading', del os.environ['DJANGO_SETTINGS_MODULE']
u'django.utils.six', super(DjangoMixin, cls).tearDownClass()
])
def test_django_db_models(self): class FindRelatedImportsTest(DjangoMixin, testlib.TestCase):
if sys.version_info >= (3, 0): klass = mitogen.master.ModuleFinder
raise unittest2.SkipTest('broken due to ancient vendored six.py')
def call(self, fullname):
import django.db.models return self.klass().find_related_imports(fullname)
related = self.call('django.db.models')
self.assertEquals(related, [ def test_django_db(self):
u'django', import django.db
u'django.conf', related = self.call('django.db')
u'django.conf.global_settings', self.assertEquals(related, [
u'django.core', 'django',
u'django.core.exceptions', 'django.core',
u'django.core.files', 'django.core.signals',
u'django.core.files.base', 'django.db.utils',
u'django.core.files.images', 'django.utils.functional',
u'django.core.files.locks', ])
u'django.core.files.move',
u'django.core.files.storage', def test_django_db_models(self):
u'django.core.files.utils', import django.db.models
u'django.core.signals', related = self.call('django.db.models')
u'django.core.validators', self.maxDiff=None
u'django.db', self.assertEquals(related, [
u'django.db.backends', u'django',
u'django.db.backends.signals', u'django.core.exceptions',
u'django.db.backends.util', u'django.db',
u'django.db.models.aggregates', u'django.db.models',
u'django.db.models.base', u'django.db.models.aggregates',
u'django.db.models.constants', u'django.db.models.base',
u'django.db.models.deletion', u'django.db.models.deletion',
u'django.db.models.expressions', u'django.db.models.expressions',
u'django.db.models.fields', u'django.db.models.fields',
u'django.db.models.fields.files', u'django.db.models.fields.files',
u'django.db.models.fields.proxy', u'django.db.models.fields.related',
u'django.db.models.fields.related', u'django.db.models.fields.subclassing',
u'django.db.models.fields.subclassing', u'django.db.models.loading',
u'django.db.models.loading', u'django.db.models.manager',
u'django.db.models.manager', u'django.db.models.query',
u'django.db.models.options', u'django.db.models.signals',
u'django.db.models.query', ])
u'django.db.models.query_utils',
u'django.db.models.related',
u'django.db.models.signals', class DjangoFindRelatedTest(DjangoMixin, testlib.TestCase):
u'django.db.models.sql', klass = mitogen.master.ModuleFinder
u'django.db.models.sql.aggregates', maxDiff = None
u'django.db.models.sql.constants',
u'django.db.models.sql.datastructures', def call(self, fullname):
u'django.db.models.sql.expressions', return self.klass().find_related(fullname)
u'django.db.models.sql.query',
u'django.db.models.sql.subqueries', def test_django_db(self):
u'django.db.models.sql.where', import django.db
u'django.db.transaction', related = self.call('django.db')
u'django.db.utils', self.assertEquals(related, [
u'django.dispatch', u'django',
u'django.dispatch.dispatcher', u'django.conf',
u'django.dispatch.saferef', u'django.conf.global_settings',
u'django.forms', u'django.core',
u'django.forms.fields', u'django.core.exceptions',
u'django.forms.forms', u'django.core.signals',
u'django.forms.formsets', u'django.db.utils',
u'django.forms.models', u'django.dispatch',
u'django.forms.util', u'django.dispatch.dispatcher',
u'django.forms.widgets', u'django.dispatch.saferef',
u'django.utils', u'django.utils',
u'django.utils._os', u'django.utils._os',
u'django.utils.crypto', u'django.utils.encoding',
u'django.utils.datastructures', u'django.utils.functional',
u'django.utils.dateformat', u'django.utils.importlib',
u'django.utils.dateparse', u'django.utils.module_loading',
u'django.utils.dates', u'django.utils.six',
u'django.utils.datetime_safe', ])
u'django.utils.decorators',
u'django.utils.deprecation', @unittest2.skipIf(
u'django.utils.encoding', condition=(sys.version_info >= (3, 0)),
u'django.utils.formats', reason='broken due to ancient vendored six.py'
u'django.utils.functional', )
u'django.utils.html', def test_django_db_models(self):
u'django.utils.html_parser', import django.db.models
u'django.utils.importlib', related = self.call('django.db.models')
u'django.utils.ipv6', self.assertEquals(related, [
u'django.utils.itercompat', u'django',
u'django.utils.module_loading', u'django.conf',
u'django.utils.numberformat', u'django.conf.global_settings',
u'django.utils.safestring', u'django.core',
u'django.utils.six', u'django.core.exceptions',
u'django.utils.text', u'django.core.files',
u'django.utils.timezone', u'django.core.files.base',
u'django.utils.translation', u'django.core.files.images',
u'django.utils.tree', u'django.core.files.locks',
u'django.utils.tzinfo', u'django.core.files.move',
u'pytz', u'django.core.files.storage',
u'pytz.exceptions', u'django.core.files.utils',
u'pytz.lazy', u'django.core.signals',
u'pytz.tzfile', u'django.core.validators',
u'pytz.tzinfo', u'django.db',
]) u'django.db.backends',
u'django.db.backends.signals',
u'django.db.backends.util',
u'django.db.models.aggregates',
u'django.db.models.base',
u'django.db.models.constants',
u'django.db.models.deletion',
u'django.db.models.expressions',
u'django.db.models.fields',
u'django.db.models.fields.files',
u'django.db.models.fields.proxy',
u'django.db.models.fields.related',
u'django.db.models.fields.subclassing',
u'django.db.models.loading',
u'django.db.models.manager',
u'django.db.models.options',
u'django.db.models.query',
u'django.db.models.query_utils',
u'django.db.models.related',
u'django.db.models.signals',
u'django.db.models.sql',
u'django.db.models.sql.aggregates',
u'django.db.models.sql.constants',
u'django.db.models.sql.datastructures',
u'django.db.models.sql.expressions',
u'django.db.models.sql.query',
u'django.db.models.sql.subqueries',
u'django.db.models.sql.where',
u'django.db.transaction',
u'django.db.utils',
u'django.dispatch',
u'django.dispatch.dispatcher',
u'django.dispatch.saferef',
u'django.forms',
u'django.forms.fields',
u'django.forms.forms',
u'django.forms.formsets',
u'django.forms.models',
u'django.forms.util',
u'django.forms.widgets',
u'django.utils',
u'django.utils._os',
u'django.utils.crypto',
u'django.utils.datastructures',
u'django.utils.dateformat',
u'django.utils.dateparse',
u'django.utils.dates',
u'django.utils.datetime_safe',
u'django.utils.decorators',
u'django.utils.deprecation',
u'django.utils.encoding',
u'django.utils.formats',
u'django.utils.functional',
u'django.utils.html',
u'django.utils.html_parser',
u'django.utils.importlib',
u'django.utils.ipv6',
u'django.utils.itercompat',
u'django.utils.module_loading',
u'django.utils.numberformat',
u'django.utils.safestring',
u'django.utils.six',
u'django.utils.text',
u'django.utils.timezone',
u'django.utils.translation',
u'django.utils.tree',
u'django.utils.tzinfo',
u'pytz',
u'pytz.exceptions',
u'pytz.lazy',
u'pytz.tzfile',
u'pytz.tzinfo',
])
if __name__ == '__main__': if __name__ == '__main__':
unittest2.main() unittest2.main()

Loading…
Cancel
Save