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

后端 未结 4 1279
既然无缘
既然无缘 2021-02-11 11:41

I updated a Django 1.7 project to Django 1.8 and now get errors when I run the tests (that are subclasses of django.test.TestCase).

Traceback (most          


        
4条回答
  •  花落未央
    2021-02-11 12:26

    Here is the complete code with the call to the base class (as suggested by @J. C. Leitão):

    import django
    import unittest
    from django.test import TestCase
    import logging
    import sys
    from builtins import classmethod
    
    class ATestTests(TestCase):
    
        @classmethod
        def setUpClass(cls):
            super(ATestTests, cls).setUpClass()
            django.setup()
            logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    
        def setUp(self):
            self._app = Application(name="a")
    
        def testtest(self):
    
            self.assertIsNotNone(self._app)
    

提交回复
热议问题