wolever / parameterized

Parameterized testing with any Python test framework
Other
833 stars 105 forks source link

Parameterized Class with Django Rest Framework APITestCase #179

Open Enorio opened 6 months ago

Enorio commented 6 months ago

I'm trying to tun the parameterized_class as in the documentation, but according to the code, its necessary to remove all test_ methods, leaving me with a class with 0 tests

I have the following;

from rest_framework.test import APITestCase

@parameterized_class("auth", ["token", "api_key"])
class TestFoo(APITestCase):

    @classmethod
    def setUpClass(cls):
        super().setUpClass()

    def setUp(self):
        super().setUp()

    def test_foo_one(self):
        self.assertEqual(...)

    def test_foo_two(self):
        self.assertEqual(...)

If I try to run a test individualy, I get AttributeError: type object 'TestFoo' has no attribute 'test_foo_one' If I run the class, no tests are found. I could use the @parameterized.expand in each test, but I didn't want to duplicate the same line everytime.

What am I missing?

Thanks :+1: