Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized Class with Django Rest Framework APITestCase #179

Open
Enorio opened this issue Mar 6, 2024 · 0 comments
Open

Parameterized Class with Django Rest Framework APITestCase #179

Enorio opened this issue Mar 6, 2024 · 0 comments

Comments

@Enorio
Copy link

Enorio commented Mar 6, 2024

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant