Update to Django 1.8 - AttributeError: django.test.TestCase has no attribute 'cls_atomics'
Solution 1:
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
.
Solution 2:
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.