This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author remi.lapeyre
Recipients chris.jerdonek, pwtail, remi.lapeyre
Date 2020-05-27.21:04:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1590613476.97.0.382506173885.issue40690@roundup.psfhosted.org>
In-reply-to
Content
I checked and FunctionTestCase seems to completely break the loader. The tests for FunctionTestCase in the standard library instantiate the class from inside the method of a TestCase so the loader never see them but even the simple test file I attached completely  breaks:

✗ python3 -m unittest
E
======================================================================
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/__main__.py", line 18, in <module>
    main(module=None)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/main.py", line 101, in __init__
    self.runTests()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/main.py", line 271, in runTests
    self.result = testRunner.run(self.test)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/runner.py", line 183, in run
    result.printErrors()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/runner.py", line 109, in printErrors
    self.printErrorList('ERROR', self.errors)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/runner.py", line 115, in printErrorList
    self.stream.writeln("%s: %s" % (flavour,self.getDescription(test)))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/runner.py", line 47, in getDescription
    return '\n'.join((str(test), doc_first_line))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/unittest/case.py", line 1472, in __str__
    self._testFunc.__name__)
AttributeError: 'str' object has no attribute '__name__'



I look at plenty of usages of FunctionTestCase on Github and all of them seemed to be false positive, they were copies of the unittest/test/test_functiontestcase.py file

The patch in the attached PR is not correct thought, it only fixes one of the loader and all of them suffer from the same issue.
History
Date User Action Args
2020-05-27 21:04:37remi.lapeyresetrecipients: + remi.lapeyre, chris.jerdonek, pwtail
2020-05-27 21:04:36remi.lapeyresetmessageid: <1590613476.97.0.382506173885.issue40690@roundup.psfhosted.org>
2020-05-27 21:04:36remi.lapeyrelinkissue40690 messages
2020-05-27 21:04:36remi.lapeyrecreate