0

I'm tring to implement an API using Django and Tastypie and trying as well to use TDD for it. Because there are several resources in the API I wanted to create a base class inheriting from the ResourceTestCase and just override on POST or PUT methods, but the test suite tries to execute the Base class as a test which is an error.

Basically I'm doing this:

class BaseResource(ResourceTestCase):
    username = 'admin'
    password = 'password'
    url = '/api/v1/'
    def get_credentials(self):
        return self.create_basic(username=self.username, password=self.password)

    def test_list_resource(self):
        resp = self.api_client.get(self.url, format = 'json', authentication=self.get_credentials())
        self.assertValidJSONResponse(resp)
        self.assertEqual(len(self.deserialize(resp)['objects']), self.l_res)
class SomeResourceTest(BaseResource):
    fixtures = ['some_fixture.json']
    def setUp(self):
        super(SomeResourceTest, self).setUp()
        self.url = '/api/v1/some/'
        self.l_res = 2

How can I exclude the Base class from being tested?

Cheluis
  • 1,402
  • 3
  • 22
  • 51
  • Related solution: http://stackoverflow.com/questions/4566910/abstract-test-case-using-python-unittest – Bartosz Dabrowski Apr 07 '14 at 10:04
  • @BartoszDabrowski Thank you very much. I was looking for some related question when I was writing this but that didn't poped up. Thanks – Cheluis Apr 07 '14 at 12:21

0 Answers0