Issue 22092: Executing some tests inside Lib/unittest/test individually throws Error (original) (raw)

Created on 2014-07-27 14:50 by vajrasky, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_test_inside_unittest.patch vajrasky,2014-07-27 15:00 review
fix_test_inside_unittest_v2.patch vajrasky,2014-08-03 15:26 review
Messages (6)
msg224136 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-07-27 14:50
For examples: $ ./python Lib/unittest/test/test_runner.py Traceback (most recent call last): File "Lib/unittest/test/test_runner.py", line 10, in from .support import LoggingResult, ResultWithNoStartTestRunStopTestRun SystemError: Parent module '' not loaded, cannot perform relative import $ ./python Lib/unittest/test/test_program.py ..................E ====================================================================== ERROR: test_discovery_from_dotted_path (__main__.Test_TestProgram) ---------------------------------------------------------------------- Traceback (most recent call last): File "Lib/unittest/test/test_program.py", line 15, in test_discovery_from_dotted_path expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__)) AttributeError: module 'unittest' has no attribute 'test' ---------------------------------------------------------------------- Ran 19 tests in 0.331s FAILED (errors=1) Here is the patch.
msg224637 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-08-03 13:38
I left a comment on rietveld. Michael, do you think changing the imports is OK, or will this cause you some troubles with the external unittest package you maintain?
msg224643 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-08-03 15:26
Here is the patch based on Ezio's review. Thanks!
msg224661 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-08-03 20:56
Patch looks fine, easy enough to change for unittest2 (if I ever have the time for a new release!)
msg224978 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-07 00:29
New changeset 668f6938fb1c by Ezio Melotti in branch '3.4': #22092: use absolute imports in unittest tests. Patch by Vajrasky Kok. http://hg.python.org/cpython/rev/668f6938fb1c New changeset 09f56fdcacf1 by Ezio Melotti in branch 'default': #22092: merge with 3.4. http://hg.python.org/cpython/rev/09f56fdcacf1 New changeset 6e5a2ac30c7e by Ezio Melotti in branch '2.7': #22092: use absolute imports in unittest tests. Patch by Vajrasky Kok. http://hg.python.org/cpython/rev/6e5a2ac30c7e
msg224979 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2014-08-07 00:31
Fixed, thanks for the report and the patch!
History
Date User Action Args
2022-04-11 14:58:06 admin set github: 66290
2014-08-07 00:31:49 ezio.melotti set status: open -> closedversions: + Python 2.7messages: + assignee: michael.foord -> ezio.melottiresolution: fixedstage: patch review -> resolved
2014-08-07 00:29:56 python-dev set nosy: + python-devmessages: +
2014-08-03 20:56:15 michael.foord set messages: +
2014-08-03 15:26:37 vajrasky set files: + fix_test_inside_unittest_v2.patchmessages: +
2014-08-03 13:38:41 ezio.melotti set assignee: michael.foordtype: behaviormessages: + stage: patch review
2014-08-01 22:51:22 terry.reedy set nosy: + terry.reedy
2014-07-28 05:37:34 serhiy.storchaka set nosy: + ezio.melotti, michael.foord
2014-07-27 15:00:10 vajrasky set files: + fix_test_inside_unittest.patch
2014-07-27 15:00:02 vajrasky set files: - fix_test_inside_unittest.patch
2014-07-27 14:50:45 vajrasky create