Example, how to use?
dz0 opened this issue · 5 comments
Hi,
I like the idea, but am confused about how to use it?
I try sth like this, but then it doesn't find tests for my auto_generator_MyModelTest
scope
class auto_generator_MyModelTest(RestTestCase, TestModelViewsetMixin):
users = [('name', '')]
def setUp(self):
from ta.api.bookables.tests.test_endpoints import setup_team
self._bookable, self.account, self.venue, self.team = setup_team(self.client, work_starts='04:00')
self.instances = [MyModel(
row=i,
col=1,
type=2,
venue=self.venue,
) for i in range(3)]
it generates tests (I can see with debug), but still doesn't fire them..?
we use
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
ok, I found the issue
generated tests are skipped by
nose/selector.py
def wantMethod(self, method):
"""Is the method a test method?
"""
....
declared = getattr(method, '__test__', None)
if declared is not None:
wanted = declared
else:
wanted = self.matches(method_name) # basically checks if startswith('test_') -- but more robust
.....
return wanted
so just attribute __test__
would be enough
but I propose to add meaningfull __name__
as well
Hi, thanks for the work. Here is an example on how we use it: https://github.com/aipescience/django-daiquiri/blob/master/daiquiri/auth/tests/test_viewsets.py. I need to spend some time on a proper README...
I will merge your PR asap. I think you are the first external user of this package. How did you find us?
Thanks - could have guessed to peek tests :)
I had similar idea, and googled among the lines "django test auto generation" :)
I merged the PR. Sorry that it took so long.