Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetUpClass error in FastFixtureTestCase: 'module' object has no attribute 'enter_transaction_management' #226

Open
shanukus98765 opened this issue Jul 29, 2015 · 4 comments

Comments

@shanukus98765
Copy link

I am using Django 1.8 with MySQL and the latest version of Django-nose pulled from this Github repo. I have used django_nose.FastFixtureTestCase instead of django.test.TestCase (as mentioned in the django-nose docs).

The test.py file in settings folder has this particular django-nose setting:

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
os.environ['REUSE_DB'] = "1"

My test_models.py (init.py contains Testcase imported from FastFixtureTestCase):

from django.db import connection
from django.test import Client

from ..models import TemplateUpload
from . import TestCase

class TemplateUploadTestCase(TestCase):

    fixtures = ['texparser_testdata']

    def setUp(self):
        self.client = Client()

    def test_correct_template_id(self):

        ieee_temp = TemplateUpload.objects.get(pk=1)
        acm_temp = TemplateUpload.objects.get(pk=2)
        self.assertEqual(ieee_temp.template_id, 1)
        self.assertEqual(acm_temp.template_id, 2)
        print('works:texparser/test_model/correct_template_id')

Error stack throwing up:

======================================================================
ERROR: test suite for <class 'texparser.tests.test_models.TemplateUploadTestCase'>
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 209, in run
    self.setUp()
  File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 292, in setUp
    self.setupContext(ancestor)
  File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 315, in setupContext
    try_run(context, names)
  File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/util.py", line 471, in try_run
    return func()
  File "/home/shanu/typeset_revamped/typeset/libs/django_nose/testcases.py", line 50, in setUpClass
    transaction.enter_transaction_management(using=db)
AttributeError: 'module' object has no attribute 'enter_transaction_management'
@jwhitlock jwhitlock added this to the Fix FastFixtureTestCase milestone Jul 29, 2015
@jwhitlock jwhitlock added the bug label Jul 29, 2015
@jwhitlock
Copy link
Contributor

FastFixtureTestCase has not been maintained since at least Django 1.6, and there are no tests to ensure it is working as intended. This could be a small fix to sync with Django's evolving transaction support, or could be a complete rewrite.

@lokeshatbigbasket
Copy link

Is this issue fixed in django 1.11???

@jklemm
Copy link

jklemm commented Oct 5, 2018

@jwhitlock so, I guess that worth remove or rewrite the FastFixtureTestCase. Keeping this class not working at the project don't make sense.

I'm using Django==1.8.19 and django-nose==1.4.4 using django_nose.FastFixtureTestCase, and still getting this error:

  | ERROR: test suite for <class 'test.MyTests'>
  | ----------------------------------------------------------------------
  | Traceback (most recent call last):
  | File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/nose/suite.py", line 209, in run
  | self.setUp()
  | File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/nose/suite.py", line 292, in setUp
  | self.setupContext(ancestor)
  | File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/nose/suite.py", line 315, in setupContext
  | try_run(context, names)
  | File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/nose/util.py", line 471, in try_run
  | return func()
  | File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/django_nose/testcases.py", line 49, in setUpClass
  | transaction.enter_transaction_management(using=db)
  | AttributeError: 'module' object has no attribute 'enter_transaction_management'

I see the issue #289, talking about test the source at #258. Is it works? Can I help to test the fix?

Please, I don't know where else to run.

@jwhitlock
Copy link
Contributor

@jklemm I'm sorry, I'm no longer using django-nose for my projects, and have moved on to pytest. I'm relying on the current users of the projects to come up with fixes and test each other's PRs.

I'm trying to collect PRs and issues related to this topic under https://github.com/django-nose/django-nose/milestone/5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants