Skip to content

Parameterized Class with Django Rest Framework APITestCase #179

@Enorio

Description

@Enorio

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 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions