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?