REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.78 KB
Close
//opt/hc_python/lib/python3.12/site-packages/aenum/test_v37.py
Text
Base64
from . import Enum from dataclasses import dataclass from unittest import TestCase class TestEnumV37(TestCase): def test_repr_with_dataclass(self): "ensure dataclass-mixin has correct repr()" # # check overridden dataclass __repr__ is used # from dataclasses import dataclass, field @dataclass(repr=False) class Foo: __qualname__ = 'Foo' a: int def __repr__(self): return 'ha hah!' class Entries(Foo, Enum): ENTRY1 = 1 self.assertEqual(repr(Entries.ENTRY1), '<Entries.ENTRY1: ha hah!>') self.assertEqual(Entries.ENTRY1.value, Foo(1)) self.assertTrue(isinstance(Entries.ENTRY1, Foo)) self.assertTrue(Entries._member_type_ is Foo, Entries._member_type_) # # check auto-generated dataclass __repr__ is not used # @dataclass class CreatureDataMixin: __qualname__ = 'CreatureDataMixin' size: str legs: int tail: bool = field(repr=False, default=True) class Creature(CreatureDataMixin, Enum): __qualname__ = 'Creature' BEETLE = ('small', 6) DOG = ('medium', 4) self.assertEqual(repr(Creature.DOG), "<Creature.DOG: size='medium', legs=4>") # # check inherited repr used # class Huh: def __repr__(self): return 'inherited' @dataclass(repr=False) class CreatureDataMixin(Huh): __qualname__ = 'CreatureDataMixin' size: str legs: int tail: bool = field(repr=False, default=True) class Creature(CreatureDataMixin, Enum): __qualname__ = 'Creature' BEETLE = ('small', 6) DOG = ('medium', 4) self.assertEqual(repr(Creature.DOG), "<Creature.DOG: inherited>") # # check default object.__repr__ used if nothing provided # @dataclass(repr=False) class CreatureDataMixin: __qualname__ = 'CreatureDataMixin' size: str legs: int tail: bool = field(repr=False, default=True) class Creature(CreatureDataMixin, Enum): __qualname__ = 'Creature' BEETLE = ('small', 6) DOG = ('medium', 4) self.assertRegex(repr(Creature.DOG), "<Creature.DOG: .*CreatureDataMixin object at .*>") if __name__ == '__main__': raise RuntimeError("'test_v3.py' should not be run by itself; it's included in 'test.py'")
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 12
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
doc
DIR
-
drwxr-xr-x
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__pycache__
DIR
-
drwxr-xr-x
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CHANGES
9.87 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LICENSE
1.49 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test.py
279.05 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_v3.py
77.83 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test_v37.py
2.78 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_common.py
8.01 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_constant.py
5.24 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_enum.py
124.07 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_py2.py
184 B
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_py3.py
406 B
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
_tuple.py
18.66 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
1.10 KB
lrw-r--r--
2025-04-04 08:01:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).