Opened 10 years ago
Closed 9 years ago
#25542 closed Cleanup/optimization (wontfix)
Discover runner will raise AttributeError when test modules raise ImportError
| Reported by: | Hiroki Kiyohara | Owned by: | nobody |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
When test modules raise ImportError, the discover runner will raise AttributeError.
It's difficult to detect the error reason.
I added a patch to check this problem.
ERROR: test_import_error_in_tests_module (test_runner.test_discover_runner.DiscoverRunnerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/hirokiky/dev/django/django/tests/test_runner/test_discover_runner.py", line 172, in test_import_error_in_tests_module
["test_discovery_sample.tests_discovery_import_error"],
File "/home/hirokiky/dev/django/django/django/test/runner.py", line 422, in build_suite
tests = self.test_loader.loadTestsFromName(label)
File "/usr/lib/python2.7/unittest/loader.py", line 100, in loadTestsFromName
parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'tests_discovery_import_error'
Attachments (1)
Change History (6)
by , 10 years ago
| Attachment: | 25542.diff added |
|---|
comment:1 by , 10 years ago
| Has patch: | unset |
|---|
comment:2 by , 10 years ago
This is very confusing behavior. I think it should be fixed even with a hack, like introspecting traceback.
comment:3 by , 10 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|---|
| Type: | Bug → Cleanup/optimization |
Accepting on the basis for further investigation.
comment:4 by , 9 years ago
I believe this issue corresponds to this Python issue, which is reported to be fixed in Python 3.5's changelog.
Note:
See TracTickets
for help on using tickets.
Not sure it can be solved or that it's Django's problem. From a python-tornado thread: