Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
test_enum has these lines:
Lines 27 to 39 in 663cf51
| defload_tests(loader, tests, ignore): | |
| tests.addTests(doctest.DocTestSuite(enum)) | |
| ifos.path.exists('Doc/library/enum.rst'): | |
| tests.addTests(doctest.DocFileSuite( | |
| '../../Doc/library/enum.rst', | |
| optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE, | |
| )) | |
| ifos.path.exists('Doc/howto/enum.rst'): | |
| tests.addTests(doctest.DocFileSuite( | |
| '../../Doc/howto/enum.rst', | |
| optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE, | |
| )) | |
| returntests |
They are problematic, because they are not executed when run as ./python.exe -m test test_enum.
Only when run with ./python.exe Lib/test/test_enum.py
Difference (on main branch):
» ./python.exe -m test test_enum Using random seed: 1578294160 0:00:00 load avg: 1.98 Run 1 test sequentially 0:00:00 load avg: 1.98 [1/1] test_enum == Tests result: SUCCESS == 1 test OK. Total duration: 856 ms Total tests: run=1,060 skipped=4 Total test files: run=1/1 Result: SUCCESS and:
» ./python.exe Lib/test/test_enum.py ...............................................................................................................................................................................................................................s.s..................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s..........................................s........................................................................................................................................FF ====================================================================== FAIL: /Users/sobolev/Desktop/cpython/Lib/test/../../Doc/library/enum.rst Doctest: enum.rst ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 2263, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for enum.rst File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/library/enum.rst", line 0 ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/library/enum.rst", line 301, in enum.rst Failed example: dir(Weekday.SATURDAY) Expected: ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value'] Got: ['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value'] ====================================================================== FAIL: /Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst Doctest: enum.rst ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 2263, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for enum.rst File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 0 ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 486, in enum.rst Failed example: @dataclass class CreatureDataMixin: size: str legs: int tail: bool = field(repr=False, default=True) Exception raised: Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run exec(compile(example.source, filename, "single", File "<doctest enum.rst[64]>", line 1, in <module> @dataclass ^^^^^^^^^ NameError: name 'dataclass' is not defined ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 492, in enum.rst Failed example: class Creature(CreatureDataMixin, Enum): BEETLE = 'small', 6 DOG = 'medium', 4 Exception raised: Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run exec(compile(example.source, filename, "single", File "<doctest enum.rst[65]>", line 1, in <module> class Creature(CreatureDataMixin, Enum): ^^^^^^^^^^^^^^^^^ NameError: name 'CreatureDataMixin' is not defined ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 496, in enum.rst Failed example: Creature.DOG Exception raised: Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run exec(compile(example.source, filename, "single", File "<doctest enum.rst[66]>", line 1, in <module> Creature.DOG ^^^^^^^^ NameError: name 'Creature' is not defined ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 530, in enum.rst Failed example: class MyEnum(Enum): __reduce_ex__ = enum.pickle_by_enum_name Exception raised: Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run exec(compile(example.source, filename, "single", File "<doctest enum.rst[70]>", line 1, in <module> class MyEnum(Enum): File "<doctest enum.rst[70]>", line 2, in MyEnum __reduce_ex__ = enum.pickle_by_enum_name ^^^^ NameError: name 'enum' is not defined. Did you mean: 'Enum'? Or did you forget to import 'enum'? ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 773, in enum.rst Failed example: Perm.X | 8 Expected: 9 Got: <Perm.X|8: 9> ---------------------------------------------------------------------- File "/Users/sobolev/Desktop/cpython/Lib/test/../../Doc/howto/enum.rst", line 1431, in enum.rst Failed example: class Color(DuplicateFreeEnum): RED = 1 GREEN = 2 BLUE = 3 GRENE = 2 Expected: Traceback (most recent call last): ... ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN' Got: Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/Lib/doctest.py", line 1374, in __run exec(compile(example.source, filename, "single", File "<doctest enum.rst[162]>", line 1, in <module> class Color(DuplicateFreeEnum): File "/Users/sobolev/Desktop/cpython/Lib/enum.py", line 570, in __new__ enum_class = super().__new__(metacls, cls, bases, classdict, **kwds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/sobolev/Desktop/cpython/Lib/enum.py", line 278, in __set_name__ enum_member.__init__(*args) File "<doctest enum.rst[161]>", line 7, in __init__ raise ValueError( ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN' Error calling __set_name__ on '_proto_member' instance 'GRENE' in 'Color' ---------------------------------------------------------------------- Ran 1062 tests in 0.876s FAILED (failures=2, skipped=4) Why? Because of
Line 29 in 663cf51
| ifos.path.exists('Doc/library/enum.rst'): |
-m test, here what os.getcwd() shows for -m test: .../cpython/build/test_python_worker_45291æBut, with ./python.exe Lib/test/test_enum.py it is: /Users/sobolev/Desktop/cpython
I've made a PR #111180 with fixes that will satisfy doctest, but I am not sure they are correct.
CC @ethanfurman
Linked PRs
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done