Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics' Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics' python-3.x python-3.x

Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics'


I believe the reason is that your setUpClass(cls) class method is not calling super. Because of that, django.tests.TestCase.setUpClass is not called and

cls.cls_atomics = cls._enter_atomics()

is not called, naturally causing cls_atomics to be undefined.

You should add super(ATestTests, cls).setUpClass() to your setUpClass.


For Django 1.8+, you should use TestCase.setUpTestData instead of TestCase.setUpClass.

class MyTests(TestCase):    @classmethod    def setUpTestData(cls):        # Set up data for the whole TestCase        cls.foo = Foo.objects.create(bar="Test")    def test1(self):        self.assertEqual(self.foo.bar, 'Test') 

The documentation is here.


I had a similar problem where a TestCase used setUpClass but did not have a tearDownClass method. My tests pass when I add an empty one:

@classmethoddef tearDownClass(cls):    pass

I also do not call django.setup.