﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32489	Add a generator function in runner.py to iterate over a test suite's test cases	Chris Jerdonek	nobody	"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)`.
"	Cleanup/optimization	new	Testing framework	dev	Normal		test suite,iterator,		Unreviewed	0	0	0	0	0	0
