Django 1.6 tests issue . Tests which are related to GET APIs run when its test class is run, however fails when all the tests are run on whole.

5 views
Skip to first unread message

Akshay Shah

unread,
Oct 14, 2017, 7:39:12 AM10/14/17
to Django users
When I run the tests of my django app with the command
python manage.py test <app_name> OR
python manage.py test

all the test cases where I am fetching some data by calling the api, they seem to fail because there is no data in the response in spite of there being in the test data. The structure which I have followed in my test suite is there is a base class of django rest framework's  APITestCase and a set_up method which creates test objects of different models used in the apis and I inherit this class in my app's test_views class for any particular api 
such as

class BaseTest(APITestCase):
      def set_up():
            '''' create the test objects which can be accessed by the main test class . eg self.person1=  Person.objects.create(.......) ''
 
     

class PipelineViewTestCase(BaseTest):
      def setUp(self):
            self.set_up()


So whenever I run the test as 
./manage.py test sales.test_views.PipelineViewTestCase
it works fine, but when I run as
./manage.py test sales or ./manage.py test
all the tests fail.
(sales is the app_name)

How can I ensure that my tests run fine as a whole? 
Please let me know if I am missing anything. Also if there are other options which I can explore. 

Thanks,
Akshay
Reply all
Reply to author
Forward
0 new messages