Author vstinner
Recipients vstinner
Date 2017-06-26.09:44:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1498470245.46.0.632048342488.issue30759@psf.upfronthosting.co.za>
In-reply-to
Content
On Python 2.7, listing *all* test cases with "./python -m test --list-cases" fails on the following test files:

* test_multibytecodec_support 
* test_robotparser

regrtest of Python 2.7 uses the test_main() function of each test file, if the function is defined. Whereas --list-cases is more written as a raw discovery function listing all cases which inherit from unittest.TestCase. These 3 files have base test cases which are "abstract" or configured below.

Options:

* Modify --list-cases to tolerate failures and report them at exit
* Modify these 2 tests to make them more "test discovery"-friendly
* Use test_main() function if available but modify its behaviour to only list test cases, instead of running them

I would prefer to limit changes in Python 2.7 branch, so IMHO the second option is the best: modify the 2 tests.


haypo@selma$ ./python -m test --list-cases test_multibytecodec_support
Traceback (most recent call last):
  ...
  File "/home/haypo/prog/python/2.7/Lib/test/test_multibytecodec_support.py", line 268, in __init__
    self.open_mapping_file().close() # test it to report the error early
  File "/home/haypo/prog/python/2.7/Lib/test/test_multibytecodec_support.py", line 273, in open_mapping_file
    return test_support.open_urlresource(self.mapfileurl)
AttributeError: 'TestBase_Mapping' object has no attribute 'mapfileurl'


haypo@selma$ ./python -m test --list-cases test_robotparser
Traceback (most recent call last):
  ...
  File "/home/haypo/prog/python/2.7/Lib/test/regrtest.py", line 1511, in list_cases
    suite = unittest.defaultTestLoader.loadTestsFromName(abstest)
  File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 103, in loadTestsFromName
    return self.loadTestsFromModule(obj)
  File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 65, in loadTestsFromModule
    tests.append(self.loadTestsFromTestCase(obj))
  File "/home/haypo/prog/python/2.7/Lib/unittest/loader.py", line 56, in loadTestsFromTestCase
    loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames))
TypeError: __init__() takes exactly 6 arguments (2 given)
History
Date User Action Args
2017-06-26 09:44:05vstinnersetrecipients: + vstinner
2017-06-26 09:44:05vstinnersetmessageid: <1498470245.46.0.632048342488.issue30759@psf.upfronthosting.co.za>
2017-06-26 09:44:05vstinnerlinkissue30759 messages
2017-06-26 09:44:04vstinnercreate