﻿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
32532	Provide friendlier error if a file path is passed as a test label when running tests	Chris Jerdonek	Chris Jerdonek	"Currently, if a user passes a file path as a test label to `DiscoverRunner`, they will get a somewhat unfriendly error that looks something like the following:

{{{
$ ./runtests.py test_runner/tests.py 
Testing against Django installed in '.../django/django' with up to 8 processes
Traceback (most recent call last):
  File ""./runtests.py"", line 593, in <module>
    options.timing,
  File ""./runtests.py"", line 325, in django_tests
    failures = test_runner.run_tests(test_labels or get_installed())
  File "".../django/django/test/runner.py"", line 721, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "".../django/django/test/runner.py"", line 612, in build_suite
    suite.addTests(tests)
  File "".../unittest/suite.py"", line 57, in addTests
    for test in tests:
TypeError: 'NoneType' object is not iterable
}}}

This is because `DiscoverRunner.build_suite()` starts out with `tests = None` in each iteration of the loop and doesn't have an `else` clause for the file path case:
https://github.com/django/django/blob/6f5dbe9dbe45b23b3befe4f1cd2ea13b6049ab96/django/test/runner.py#L574-L600

I imagine this is a common error because the help string tells the user to use ""paths"":

> ""Optional path(s) to test modules; e.g. ""i18n"" or ""i18n.tests.TranslationTests.test_lazy_objects"".

but without saying that file paths aren't allowed.

A more friendly error message could tell the user that they provided a path to a file, but that only dotted module paths and directory paths are supported.
"	Cleanup/optimization	closed	Testing framework	3.1	Normal	fixed	DiscoverRunner,test labels		Ready for checkin	1	0	0	0	0	0
