Failing tests on Fedora 17 #254

Closed
bkabrda opened this Issue May 9, 2012 · 4 comments

Projects

None yet

2 participants

@bkabrda
bkabrda commented May 9, 2012

Hi, I'm getting some test failures on F17 in chrooted environment (strangely, they pass in non-chrooted environment...):

ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.)

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/site-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/builddir/build/BUILD/lettuce-0.1.35/lettuce/django/init.py", line 19, in
from lettuce.django.server import Server
File "/builddir/build/BUILD/lettuce-0.1.35/lettuce/django/server.py", line 30, in
from django.core.servers.basehttp import WSGIServer
File "/usr/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 26, in
from django.views import static
File "/usr/lib/python2.7/site-packages/django/views/static.py", line 95, in
template_translatable = ugettext_noop(u"Index of %(directory)s")
File "/usr/lib/python2.7/site-packages/django/utils/translation/init.py", line 75, in gettext_noop
return _trans.gettext_noop(message)
File "/usr/lib/python2.7/site-packages/django/utils/translation/init.py", line 48, in getattr
if settings.USE_I18N:
File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/usr/lib/python2.7/site-packages/django/conf/init.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

FAIL: lettuce should serve admin static files properly on Django 1.3

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/test_grocery.py", line 48, in test_django_admin_media_serving_on_django_13
assert_equals(status, 0, out)
AssertionError: Preparing to serve django's admin site static files...
Django's builtin server is running at 0.0.0.0:7000
Running on port 7000 ... OK
Fetching admin media ... OK
Fetching static files ... OK
Fetching CSS files: ... OK
Fetching javascript files: ... FAILED

Traceback (most recent call last):
File "/builddir/build/BUILD/lettuce-0.1.35/lettuce/core.py", line 117, in call
ret = self.function(self.step, _args, *_kw)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/django/grocery/features/step_definitions/grocery_steps.py", line 65, in then_all_the_responses_have_mime_type_group1
assert_equals(content_type, group1, 'failed at %s' % url)
File "/usr/lib64/python2.7/unittest/case.py", line 549, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/lib64/python2.7/unittest/case.py", line 542, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: failed at http://localhost:7000/media/js/actions.js

1 feature (0 passed)
5 scenarios (4 passed)
14 steps (1 failed, 13 passed)

FAIL: lettuce should serve admin static files properly on Django 1.2.5

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/test_grocery.py", line 74, in test_django_admin_media_serving_on_django_125
assert_equals(status, 0, out)
AssertionError: Preparing to serve django's admin site static files...
Django's builtin server is running at 0.0.0.0:7000
Running on port 7000 ... OK
Fetching admin media ... OK
Fetching static files ... OK
Fetching CSS files: ... OK
Fetching javascript files: ... FAILED

Traceback (most recent call last):
File "/builddir/build/BUILD/lettuce-0.1.35/lettuce/core.py", line 117, in call
ret = self.function(self.step, _args, *_kw)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/django/grocery/features/step_definitions/grocery_steps.py", line 65, in then_all_the_responses_have_mime_type_group1
assert_equals(content_type, group1, 'failed at %s' % url)
File "/usr/lib64/python2.7/unittest/case.py", line 549, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/lib64/python2.7/unittest/case.py", line 542, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: failed at http://localhost:7000/media/js/actions.js

1 feature (0 passed)
5 scenarios (4 passed)
14 steps (1 failed, 13 passed)

FAIL: settings.LETTUCE_SERVE_ADMIN_MEDIA forces lettuce to serve admin assets

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/test_grocery.py", line 106, in test_django_admin_media_serving_forced_by_setting
assert_equals(status, 0, out)
AssertionError: Preparing to serve django's admin site static files (as per settings.LETTUCE_SERVE_ADMIN_MEDIA=True)...
Django's builtin server is running at 0.0.0.0:7000
Running on port 7000 ... OK
Fetching static files ... OK
Fetching CSS files: ... OK
Fetching javascript files: ... FAILED

Traceback (most recent call last):
File "/builddir/build/BUILD/lettuce-0.1.35/lettuce/core.py", line 117, in call
ret = self.function(self.step, _args, *_kw)
File "/builddir/build/BUILD/lettuce-0.1.35/tests/integration/django/grocery/features/step_definitions/grocery_steps.py", line 65, in then_all_the_responses_have_mime_type_group1
assert_equals(content_type, group1, 'failed at %s' % url)
File "/usr/lib64/python2.7/unittest/case.py", line 549, in assertEqual
assertion_func(first, second, msg=msg)
File "/usr/lib64/python2.7/unittest/case.py", line 542, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: failed at http://localhost:7000/media/js/actions.js

1 feature (0 passed)
4 scenarios (3 passed)
10 steps (1 failed, 9 passed)


Ran 254 tests in 10.008s

FAILED (errors=1, failures=3)

The 3 failures seem to be caused by javascript having mime-type application/x-javascript, the first error I really don't know. As I have mentioned, I get no failures nor errors in non-chrooted environment. Anyone has a clue what's going on here?

Thanks a lot!

@gabrielfalcao
Owner

Unfortunately I don't have a fedora box to test it. I need to address this issue

@bkabrda
bkabrda commented Jun 27, 2012

Got it!
The problem is actually in Python itself. Django uses Python's mimetypes to determine javascript mimetype. Python in turn uses some default system files to get mimetypes - when none these files are present, Python uses some predefined constants, in which javascript mimetype is set to 'application/x-javascript'.
So in my chrooted environment, there were no files with default mimetypes => Python used it's wrongly predefined one. I consider this to be Python's issue, not Lettuce's, as according to IANA specification, 'application-javascript' should be used.
I reported this to Python bug tracker here: http://bugs.python.org/issue15199 and I'm closing this issue.

@bkabrda bkabrda closed this Jun 27, 2012
@gabrielfalcao
Owner

Great @bkabrda thank you!

@bkabrda
bkabrda commented Aug 21, 2012

Just an update - my patch has been accepted and will be part of next Python releases, both Python 2 and Python 3 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment