2

We are using django as our main backend, we use django-nose as our unit test framework. We have recently upgraded from django 1.3 to 1.11, a huge change, we are facing the following issue. When we are django 1.3, the unit tests ran fine, but with django 1.11, it's throwing the below error.

    transaction.enter_transaction_management(using=db)
    AttributeError: 'module' object has no attribute 
                      'enter_transaction_management'

We found that there is an opened issue going on in django-nose github. I thought of two solutions for this problem. 1. As I can understand that enter_transaction_management and managed functions are deprecated/removed in django 1.11, were there any replacements or alternatives provided in 1.11??? 2. What are the good alternatives to django-nose??

Please help

These are the github issues.

https://github.com/django-nose/django-nose/issues/226

https://github.com/django-nose/django-nose/issues/289

https://github.com/django-nose/django-nose/pull/258

  • Here's a note from the django docs about `TransactionTestCase` and what changed from Django 1.8 onwards: Changed in Django 1.8: In older versions of Django, the effects of transaction commit and rollback could not be tested within a TestCase. With the completion of the deprecation cycle of the old-style transaction management in Django 1.8, transaction management commands (e.g. transaction.commit()) are no longer disabled within TestCase. – dirkgroten Oct 27 '17 at 08:48
  • So you can just use Django's standard TransactionTestCase and use transactions as you would in your normal views inside your test cases. No need to use the extra function provided by django.nose for this. – dirkgroten Oct 27 '17 at 08:49
  • @dirkgroten hi, thanks for reply... I have tried as you suggested, but the problem is it's not creating entries in database properly, the error I am getting is some field doesn't have a default value, but actually it does have a default value set. Don't know why??? do you have any idea on this... – lokesh sanapalli Oct 27 '17 at 13:50
  • sorry, would need to have more information: what error exactly? what's the test you're trying? which model? – dirkgroten Oct 27 '17 at 14:02
  • hey @dirkgroten django-nose not re-using the database even with REUSE_DB=1 setting, do you have any idea on this??? – lokesh sanapalli Nov 07 '17 at 08:24
  • sorry I can't help here. No idea. – dirkgroten Nov 09 '17 at 11:18

0 Answers0