google-code-export / django-modeltranslation

Automatically exported from code.google.com/p/django-modeltranslation
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

not registered for translation in django_webtest test #68

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup all translations (worked on runned site)
2. Write integration test with django_webtest
3. Run tests

Instead of run webtest like this

from django_webtest import WebTest

class ProfileTest(WebTest):
    """
    Проверка логина.
    """
    # TODO смена пароля, установка ника, установка мыла
    def test_show(self):
        """
        Проверка отображения страницы профиля.
        """
        page = self.app.get('/ru/profile', user='user1')

        assert u'Текущий пароль' in page

i see error this:

Traceback (most recent call last):
  File "/project/app0/tests.py", line 15, in test_logout_and_login
    page = self.app.get('/ru/sauth/login', user='user1')
  File "/usr/local/lib/python2.7/dist-packages/django_webtest/__init__.py", line 71, in get
    url, params, headers, extra_environ, status, expect_errors)
  File "/usr/local/lib/python2.7/dist-packages/webtest/app.py", line 753, in get
    expect_errors=expect_errors)
  File "/usr/local/lib/python2.7/dist-packages/django_webtest/__init__.py", line 42, in do_request
    response = super(DjangoTestApp, self).do_request(req, status, expect_errors)
  File "/usr/local/lib/python2.7/dist-packages/webtest/app.py", line 1052, in do_request
    res = req.get_response(app, catch_exc_info=True)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1145, in get_response
    application, catch_exc_info=True)
  File "/usr/local/lib/python2.7/dist-packages/webob/request.py", line 1118, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webtest/lint.py", line 173, in lint_app
    iterator = application(environ, start_response_wrapper)
  File "/usr/local/lib/python2.7/dist-packages/django_webtest/middleware.py", line 77, in __call__
    return self.app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
    return self.application(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
    response = self.get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 169, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 89, in get_response
    response = middleware_method(request)
  File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 67, in process_request
    if (not _is_valid_path(request.path_info, urlconf) and
  File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 154, in _is_valid_path
    urlresolvers.resolve(path, urlconf)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 342, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 250, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 279, in _get_url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 274, in _get_urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/project/urls.py", line 8, in <module>
    admin.autodiscover()
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
    import_module('%s.admin' % app)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/project/app1/admin.py", line 44, in <module>
    admin.site.register(ContentType, ContentTypeAdmin)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 100, in register
    self._registry[model] = admin_class(model, self)
  File "/usr/local/lib/python2.7/dist-packages/modeltranslation/admin.py", line 68, in __init__
    trans_opts = translator.get_options_for_model(self.model)
  File "/usr/local/lib/python2.7/dist-packages/modeltranslation/translator.py", line 236, in get_options_for_model
    'translation' % model.__name__)
NotRegistered: The model "ContentType" is not registered for translation

System:
python 2.7.2+
django 1.3.1
django-modeltranslation 0.3.2
ubuntu 11.10 x64

I try use nose runner from django-nose and have another problem with same model 
- his always raise "AlreadyRegistered" admin error.

Original issue reported on code.google.com by qnub...@gmail.com on 6 Jan 2012 at 1:43

GoogleCodeExporter commented 9 years ago
same error if i use native django

from django.test.client import Client

Original comment by qnub...@gmail.com on 6 Jan 2012 at 3:24

GoogleCodeExporter commented 9 years ago
No. Integration (functional) tests completely not work with modeltranslation... 
:(

I've try to rename ContentType or completely remove model from project - not 
any affect.

Only anoher model is NotRegistered...

Original comment by qnub...@gmail.com on 7 Jan 2012 at 9:19

GoogleCodeExporter commented 9 years ago
I find point to check your code - exception raise when test try to reverse 
resolve URL trough from django.core.urlresolvers.reverse function. If i use 
direct links to buld request object - all ok, if i try reverse calculate url 
for django.test.client.RequestFactory.get - your NotRegistered exception raised!

Original comment by qnub...@gmail.com on 7 Jan 2012 at 5:33

GoogleCodeExporter commented 9 years ago
When run django.test.client.Client tests error raised when template run {% url 
urlname %} tag for reverse url resolving

Any suggestions?

Original comment by qnub...@gmail.com on 7 Jan 2012 at 6:19

GoogleCodeExporter commented 9 years ago
how fix this ploblem ?

Original comment by Lehab...@gmail.com on 24 Feb 2012 at 11:48

GoogleCodeExporter commented 9 years ago
i've remove modeltranslation

Original comment by qnub...@gmail.com on 24 Feb 2012 at 12:23

GoogleCodeExporter commented 9 years ago
try this:
in settings.py remove the project name from the import:
MODELTRANSLATION_TRANSLATION_REGISTRY = 'project_name.translation'

Change it to:
MODELTRANSLATION_TRANSLATION_REGISTRY = 'translation'

Original comment by anto...@projecto24.com on 11 Jun 2012 at 1:04

GoogleCodeExporter commented 9 years ago
Project moved to Github. All issues have been migrated preserving their id. All 
remaining open issues on GoogleCode are closed. New project url: 
https://github.com/deschler/django-modeltranslation

Original comment by eschler on 22 Oct 2012 at 8:22