#32489: Add a generator function in runner.py to iterate over a test suite's
test
cases
-------------------------------------+-------------------------------------
Reporter: Chris | Owner: nobody
Jerdonek |
Type: | Status: new
Cleanup/optimization |
Component: Testing | Version: master
framework | Keywords: test
Severity: Normal | suite,iterator,
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
There are four functions or methods in
[https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/test/runner.py
test/runner.py] that need to iterate over a test suite's test cases:
*
[https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/test/runner.py#L684-L699
DiscoverRunner._get_databases()]
*
[https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/test/runner.py#L792-L815
partition_suite_by_type()]
*
[https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/test/runner.py#L818-L828
partition_suite_by_case()]
*
[https://github.com/django/django/blob/64a0d1ef6e7a6739148996e9584bbb61fe3dcc60/django/test/runner.py#L831-L848
filter_tests_by_tags()]
Each of these functions is a little harder to understand than it needs to
be because each needs to contain the logic of how to iterate over a test
suite, which isn't obvious. In particular, they're all implemented as
recursive functions, since test suites can contain test suites.
If `runner.py` contained a single helper function that accepts a test
suite instance and returns an iterator of the test suite's test cases,
then each of those four functions could be simplified. They could contain
a simple `for` loop over the iterator's return value and not have to be
recursive.
The helper function would be pretty simple and could itself be recursive
(but it wouldn't need to be). It could be called something like
`iter_test_cases(suite)`.
--
Ticket URL: <https://code.djangoproject.com/ticket/32489>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.c03edaeaaf85939bbf16cc6ab6c757c1%40djangoproject.com.