user2876296
user2876296

Reputation: 97

Python/Django tests running only one test at a time

I have a unittest for my view

class TestFromAllAdd(TestCase):
    fixtures = ['staging_accounts_user.json',
        'staging_main_category.json',
        'staging_main_dashboard.json',
        'staging_main_location.json',
        'staging_main_product.json',
        'staging_main_shoppinglist.json']

    def setUp(self):
        self.factory = RequestFactory()
        self.c = Client()
        self.c.login(username='admin', password='admin')

    def from_all_products_html404_test(self):
        request = self.factory.post('main/adding_from_all_products', {'product_id': ''})
        request.user = User.objects.get(username= 'admin')
        response = adding_from_all_products(request)
        self.assertEqual(response.status_code, 404)

But I have a few more classes with tests and I cant run them all at the same time: python manage.py test main doesnt run tests, but if i run; python manage.py test main.TestFromAllAdd.from_all_products_html404_test , runs one test;

Upvotes: 0

Views: 600

Answers (2)

user2876296
user2876296

Reputation: 97

Python testing requires that all methods start with test word, so my method must be renamed test_from_all_products_html404_test

Upvotes: 1

Daniel Roseman
Daniel Roseman

Reputation: 599590

Unittest methods need to begin with the word test (not end with it). Your method should be called test_from_all_products_html404.

Upvotes: 1

Related Questions