django-nose icon indicating copy to clipboard operation
django-nose copied to clipboard

'Template' has no attribute '_original_render'

Open szechyjs opened this issue 10 years ago • 7 comments

At the end of the nose tests I receive the following error...

Destroying test database for alias 'default' (':memory:')...
Traceback (most recent call last):
  File "setup.py", line 69, in <module>
    setup_package()
  File "setup.py", line 63, in setup_package
    'reportmanager = lost.services.ReportManagerServer:main'
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "services-setuptools/venv/lib/python2.7/site-packages/setuptools/command/test.py", line 146, in run
    self.with_project_on_sys_path(self.run_tests)
  File "services-setuptools/venv/lib/python2.7/site-packages/setuptools/command/test.py", line 127, in with_project_on_sys_path
    func()
  File "services-setuptools/venv/lib/python2.7/site-packages/setuptools/command/test.py", line 167, in run_tests
    testRunner=self._resolve_as_ep(self.test_runner),
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 94, in __init__
    self.parseArgs(argv)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 149, in parseArgs
    self.createTests()
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 158, in createTests
    self.module)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 130, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py", line 115, in loadTestsFromName
    test = obj()
  File "/Users/jared/Dev/BSI/marrts/services-setuptools/lost/runtests.py", line 17, in runtests
    failures = test_runner.run_tests(['lost'])
  File "services-setuptools/venv/lib/python2.7/site-packages/django_nose/runner.py", line 200, in run_tests
    result = self.run_suite(nose_argv)
  File "services-setuptools/venv/lib/python2.7/site-packages/django_nose/runner.py", line 147, in run_suite
    addplugins=plugins_to_add)
  File "services-setuptools/venv/lib/python2.7/site-packages/nose-1.3.3-py2.7.egg/nose/core.py", line 121, in __init__
    **extra_args)
  File "/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 95, in __init__
    self.runTests()
  File "services-setuptools/venv/lib/python2.7/site-packages/nose-1.3.3-py2.7.egg/nose/core.py", line 207, in runTests
    result = self.testRunner.run(self.test)
  File "services-setuptools/venv/lib/python2.7/site-packages/nose-1.3.3-py2.7.egg/nose/core.py", line 68, in run
    self.config.plugins.finalize(result)
  File "services-setuptools/venv/lib/python2.7/site-packages/nose-1.3.3-py2.7.egg/nose/plugins/manager.py", line 99, in __call__
    return self.call(*arg, **kw)
  File "services-setuptools/venv/lib/python2.7/site-packages/nose-1.3.3-py2.7.egg/nose/plugins/manager.py", line 167, in simple
    result = meth(*arg, **kw)
  File "services-setuptools/venv/lib/python2.7/site-packages/django_nose/plugin.py", line 81, in finalize
    self.runner.teardown_test_environment()
  File "services-setuptools/venv/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/test/runner.py", line 126, in teardown_test_environment
    teardown_test_environment()
  File "services-setuptools/venv/lib/python2.7/site-packages/Django-1.6.5-py2.7.egg/django/test/utils.py", line 119, in teardown_test_environment
    Template._render = Template._original_render
AttributeError: type object 'Template' has no attribute '_original_render'

From what I can tell from the stack trace this is originating from django_nose/plugin.py:81 which is the following...

self.runner.teardown_databases(self.old_names)

I only receive this error when running through django_nose, when using nosetest on its own the test exits cleanly.

szechyjs avatar Jul 07 '14 15:07 szechyjs

Happens to me as well.

pedrospdc avatar Apr 22 '15 10:04 pedrospdc

Does this still happen with django-nose 1.4? Do you have a public project that demonstrates the error?

jwhitlock avatar Jul 02 '15 21:07 jwhitlock

It's been a while, I don't remember where I got that error. I'm sorry.

pedrospdc avatar Jul 03 '15 09:07 pedrospdc

I just got this same error this morning on django-nose 1.4.1, with nose 1.3.7 and django 1.8.3

Unfortunately, this isn't on a public project I can share.

greylurk avatar Aug 12 '15 15:08 greylurk

@greylurk Thanks for confirming.

jwhitlock avatar Aug 13 '15 12:08 jwhitlock

Actually, I discovered the problem, and it's unrelated to the django-nose package. I was tearing down the django test setup twice in my own code. I'm not sure why it suddenly started breaking just yesterday, but it doesn't appear related to django-nose.

greylurk avatar Aug 13 '15 15:08 greylurk

@greylurk is right. I've just run into similar problems using behave 1.2.5 so it's not strictly related to django-nose.

And without going into details I've also called teardown_test_environment twice which lead to the very same exception.

glujan avatar May 21 '16 15:05 glujan