Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Testing: DatabaseCreation' object has no attribute '_rollback_works'

I have written a example test and I'm trying to run it without creating a new database every time.

The first time I run my test everything is ok (takes sometime due to building the DB):

> REUSE_DB=1 python manage.py test contacts
Ran 1 test in 0.251s

The second time I get the following error:

> REUSE_DB=1 python manage.py test contacts
nosetests --verbosity 1 contacts
AttributeError: 'DatabaseCreation' object has no attribute '_rollback_works'

Why and how do I solve? Thanks.

My Test:

class ExampleTestCase(TestCase):

def test_contact_page(self):
    resp = self.client.get('/contact/single/')
    self.assertEqual(resp.status_code, 200)

Settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG

INSTALLED_APPS += (
    'django_nose',
)

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
like image 396
GrantU Avatar asked Jun 24 '13 12:06

GrantU


1 Answers

Just use nose from github and you're good to go! I belive this is your issue:

https://github.com/jbalogh/django-nose/pull/95

I came across this a long while ago, it is now fixed on the github master, but unfortunately django-nose is not updated on pypi since last year..

like image 168
ppetrid Avatar answered Nov 04 '22 20:11

ppetrid