Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.maint.python > #7782 > unrolled thread
| Started by | Brian May <bam@debian.org> |
|---|---|
| First post | 2015-10-24 04:20 +0200 |
| Last post | 2015-10-25 02:30 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.debian.maint.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Bug#802839: django-celery: python 3 tests not invoked and break Brian May <bam@debian.org> - 2015-10-24 04:20 +0200
Bug#802839: django-celery: python 3 tests not invoked and break Robert Collins <robertc@robertcollins.net> - 2015-10-24 06:00 +0200
Bug#802839: django-celery: python 3 tests not invoked and break Brian May <bam@debian.org> - 2015-10-25 02:30 +0200
| From | Brian May <bam@debian.org> |
|---|---|
| Date | 2015-10-24 04:20 +0200 |
| Subject | Bug#802839: django-celery: python 3 tests not invoked and break |
| Message-ID | <qmWB4-3gM-5@gated-at.bofh.it> |
Brian May <bam@debian.org> writes:
> ======================================================================
> FAIL: test_discovery_with_broken (djcelery.tests.test_discovery.TestDiscovery)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/brian/tree/debian/python-modules/django-celery/tests/../djcelery/tests/test_discovery.py", line 45, in test_discovery_with_broken
> self.assertEqual(log, [])
> AssertionError: Lists differ: [<warnings.WarningMessage object at 0x7f2b03474c88>] != []
>
> First list contains 1 additional elements.
> First extra element 0:
> {message : ResourceWarning("unclosed file <_io.TextIOWrapper name='/home/brian/tree/debian/python-modules/django-celery/tests/someapp/tasks.py' mode='r' encoding='utf-8'>",), category : 'ResourceWarning', filename : '/home/brian/tree/debian/python-modules/django-celery/tests/../djcelery/loaders.py', lineno : 204, line : None}
>
> - [<warnings.WarningMessage object at 0x7f2b03474c88>]
> + []
>
> ----------------------------------------------------------------------
> Ran 66 tests in 0.340s
>
> FAILED (errors=2, failures=1)
That includes a debug message I put in. Oops. Showing the warning object
that caused the problem.
It seems that Python3 is generating an unexpected error ("unclosed
file") that is upsetting the test because it expects 0 warnings.
Any ideas how to fix this? It doesn't appear to be this project that is
producing the warning, maybe that comes from Django.
Or should I just remove the Assert?
The code in question that appears to be producing the warning:
def autodiscover():
"""Include tasks for all applications in ``INSTALLED_APPS``."""
global _RACE_PROTECTION
if _RACE_PROTECTION:
return
_RACE_PROTECTION = True
try:
if django.VERSION < (1, 7):
return filter(None, [find_related_module(app, 'tasks')
for app in settings.INSTALLED_APPS])
else:
from django.apps import apps
return filter(None, [find_related_module(app.name, 'tasks')
for app in apps.get_app_configs()])
finally:
_RACE_PROTECTION = False
This is in git, in the expected python-modules location.
--
Brian May <bam@debian.org>
[toc] | [next] | [standalone]
| From | Robert Collins <robertc@robertcollins.net> |
|---|---|
| Date | 2015-10-24 06:00 +0200 |
| Message-ID | <qmY9Q-5tz-3@gated-at.bofh.it> |
| In reply to | #7782 |
I'd probably shut that warning up using the warnings module API rather than weaking the test more broadly. Also - track down and file a bug on the leak source.
[toc] | [prev] | [next] | [standalone]
| From | Brian May <bam@debian.org> |
|---|---|
| Date | 2015-10-25 02:30 +0200 |
| Message-ID | <qnhm9-7Wg-1@gated-at.bofh.it> |
| In reply to | #7783 |
Robert Collins <robertc@robertcollins.net> writes:
> I'd probably shut that warning up using the warnings module API rather
> than weaking the test more broadly.
Might be the best thing.
> Also - track down and file a bug on the leak source.
How *do* you track these down? The warning doesn't say where the file
was opened.
Anyway, I suspect the problem is with the call to imp.find_module(),
which is a depreciated function in Python 3.4:
It ends with:
file = open(file_path, mode, encoding=encoding)
return file, file_path, (suffix, mode, type_)
djcelery.loaders.find_related_module() calls this function and ignores
the result. Which obviously means the file doesn't get closed.
try:
imp.find_module(related_name, app_path)
except ImportError:
return
return importlib.import_module('{0}.{1}'.format(app, related_name))
Need to think about if it is worth fixing, and what the best fix is.
--
Brian May <bam@debian.org>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.maint.python
csiph-web