summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-112328: Make EnumDict usable on its own and document it (GH-123669)Petr Viktorin2024-12-201-1/+32
| | | | | Co-authored-by: Rafi <rafi.promit@gmail.com> Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua> Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-125259: Fix error notes removal in enum initialization (GH-125647)Mario Šaško2024-10-221-0/+19
|
* gh-125710: [Enum] fix hashable<->nonhashable comparisons for member values ↵Ethan Furman2024-10-221-0/+7
| | | | (GH-125735)
* Fix typos (#123775)algonell2024-09-091-1/+1
|
* gh-120361: Add `nonmember` test with enum flags inside to `test_enum` ↵Nikita Sobolev2024-06-141-0/+21
| | | | | (GH-120364) * gh-120361: Add `nonmember` test with enum flags inside to `test_enum`
* gh-117663: [Enum] fix _simple_enum's detection of aliases (GH-117664)Ethan Furman2024-04-091-1/+51
|
* gh-116600: [Enum] fix global Flag repr (GH-116615)Ethan Furman2024-03-111-0/+2
| | | | | | | * and fix global flag repr * Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
* gh-116040: [Enum] fix test_empty_names test (GH-116508)Ethan Furman2024-03-111-11/+7
| | | * and fix _not_given usage
* gh-116040: [Enum] fix by-value calls when second value is falsey; e.g. ↵Ethan Furman2024-03-071-0/+23
| | | | Cardinal(1, 0) (GH-116072)
* gh-115821: [Enum] better error message for calling super().__new__() (GH-116063)Ethan Furman2024-02-281-1/+12
| | | | docs now state to not call super().__new__ if super().__new__ is called, a better error message is now used
* gh-115539: Allow enum.Flag to have None members (GH-115636)Jason Zhang2024-02-191-0/+16
|
* gh-115252: Fix test_enum with -OO mode again (GH-115334)Serhiy Storchaka2024-02-131-5/+5
|
* gh-97959: Fix rendering of routines in pydoc (GH-113941)Serhiy Storchaka2024-02-111-5/+5
| | | | | | | | | | * Class methods no longer have "method of builtins.type instance" note. * Corresponding notes are now added for class and unbound methods. * Method and function aliases now have references to the module or the class where the origin was defined if it differs from the current. * Bound methods are now listed in the static methods section. * Methods of builtin classes are now supported as well as methods of Python classes.
* gh-115252: Fix `test_enum` with `-OO` mode (GH-115253)Nikita Sobolev2024-02-101-3/+14
|
* gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871)Ethan Furman2024-02-041-0/+34
| | | | | | | | | | | | | | | | | | | | | | | Update documentation with `__new__` and `__init__` entries. Support use of `auto()` in tuple subclasses on member assignment lines. Previously, auto() was only supported on the member definition line either solo or as part of a tuple: RED = auto() BLUE = auto(), 'azul' However, since Python itself supports using tuple subclasses where tuples are expected, e.g.: from collections import namedtuple T = namedtuple('T', 'first second third') def test(one, two, three): print(one, two, three) test(*T(4, 5, 6)) # 4 5 6 it made sense to also support tuple subclasses in enum definitions.
* gh-114149: [Enum] revert #114160 and add more tuple-subclass tests (GH-114215)Ethan Furman2024-01-181-6/+21
| | | This reverts commit 05e142b1543eb9662d6cc33722e7e16250c9219f.
* gh-114149: [Enum] fix tuple subclass handling when using custom __new__ ↵Ethan Furman2024-01-171-0/+16
| | | | (GH-114160)
* gh-112328: [Enum] Make some private attributes public. (GH-112514)Ethan Furman2023-12-051-2/+84
| | | | | | | | | | | | | * [Enum] Make some private attributes public. - ``_EnumDict`` --> ``EnumDict`` - ``EnumDict._member_names`` --> ``EnumDict.member_names`` - ``Enum._add_alias_`` - ``Enum._add_value_alias_`` --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-111181: Fix enum doctests (GH-111180)Nikita Sobolev2023-10-301-6/+11
| | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-110905: [Enum] minor fixes and cleanup (GH-110906)Pieter Eendebak2023-10-161-1/+1
|
* gh-109022: [Enum] require `names=()` to create empty enum type (GH-109048)Ethan Furman2023-09-081-4/+7
| | | | | | | add guard so that ``Enum('bar')`` raises a TypeError instead of creating a new enum class called `bar`. To create the new but empty class, use: huh = Enum('bar', names=())
* gh-108840: Remove unused `TestEnumTypeSubclassing` from `test_enum` (#108841)Nikita Sobolev2023-09-051-2/+0
|
* gh-108682: [Enum] raise TypeError if super().__new__ called in custom ↵Ethan Furman2023-08-311-55/+229
| | | | | | | | | | | __new__ (GH-108704) When overriding the `__new__` method of an enum, the underlying data type should be created directly; i.e. . member = object.__new__(cls) member = int.__new__(cls, value) member = str.__new__(cls, value) Calling `super().__new__()` finds the lookup version of `Enum.__new__`, and will now raise an exception when detected.
* gh-108494: Argument Clinic: fix support of Limited C API (GH-108536)Serhiy Storchaka2023-08-281-2/+4
|
* gh-105522: [Enum] Correctly handle possible exceptions during testing ↵Nikita Sobolev2023-08-161-54/+96
| | | | (GH-105523)
* gh-106602: [Enum] Add __copy__ and __deepcopy__ (GH-106666)Prince Roshan2023-07-121-0/+8
|
* gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (#106468)Ethan Furman2023-07-111-55/+83
| | | | | | | | | | | For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0)
* gh-105497: [Enum] Fix Flag inversion when alias/mask members exist. (GH-105542)Ethan Furman2023-06-091-0/+39
| | | When inverting a Flag member (or boundary STRICT), only consider other canonical flags; when inverting an IntFlag member (or boundary KEEP), also consider aliases.
* gh-105332: [Enum] Fix unpickling flags in edge-cases (GH-105348)Nikita Sobolev2023-06-081-1/+27
| | | | | * revert enum pickling from by-name to by-value Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-104764: [Enum] fix 3.13-specific tests (GH-104779)Ethan Furman2023-05-231-9/+9
|
* gh-104764: Skip failing tests in test_enum that started failing. (#104765)T. Wouters2023-05-221-7/+7
| | | Skip failing tests in test_enum that started failing when the version was bumped to 3.13.
* gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)Ethan Furman2023-04-181-0/+17
| | | | | | | | | | | | | | | | | | For example: class Book(StrEnum): title = auto() author = auto() desc = auto() Book.author.desc is Book.desc but Book.author.title() == 'Author' is commonly expected. Using upper-case member names avoids this confusion and possible performance impacts. Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
* gh-103479: [Enum] require __new__ to be considered a data type (GH-103495)Ethan Furman2023-04-131-6/+7
| | | a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type
* gh-103365: [Enum] STRICT boundary corrections (GH-103494)Ethan Furman2023-04-131-8/+39
| | | | | | STRICT boundary: - fix bitwise operations - make default for Flag
* gh-93910: [Enum] remove member.member deprecation (GH-103236)Ethan Furman2023-04-061-21/+8
| | | | i.e. Color.RED.BLUE is now officially supported.
* gh-102549: [Enum] fail enum creation when data type raises in __init__ ↵Ethan Furman2023-03-311-0/+20
| | | | (GH-103149)
* gh-102558: [Enum] better handling of non-Enum EnumType classes (GH-103060)Ethan Furman2023-03-271-1/+0
|
* gh-103056: [Enum] ensure final _generate_next_value_ is a staticmethod ↵Ethan Furman2023-03-271-0/+17
| | | | (GH-103062)
* gh-102558: [Enum] fix AttributeError during member repr() (GH-102601)Dong-hee Na2023-03-231-1/+8
|
* Rename redundant enum tests so that they run (#102535)JosephSBoyle2023-03-141-3/+2
|
* gh-102515: Remove unused imports in the `Lib/` directory (#102516)Alex Waygood2023-03-081-2/+0
|
* gh-101541: [Enum] create flag psuedo-member without calling original __new__ ↵Ethan Furman2023-02-061-0/+40
| | | | (GH-101590)
* gh-100039: enhance __signature__ to work with str and callables (GH-100168)Ethan Furman2022-12-161-2/+23
| | | | | Callables should be either class- or static-methods. Enum now uses the classmethod version to greatly improve the help given for enums and flags.
* gh-100098: [Enum] insist on actual tuples, no subclasses, for auto (GH-100099)Ethan Furman2022-12-081-0/+13
| | | | | | When checking for auto() instances, only top-level usage is supported, which means either alone or as part of a regular tuple. Other containers, such as lists, dicts, or namedtuples, will not have auto() transformed into a value.
* [Enum] Remove unused code from `test_enum.py` (GH-96986)Nikita Sobolev2022-12-071-14/+0
|
* gh-94943: [Enum] improve repr() when inheriting from a dataclass (GH-99740)Ethan Furman2022-12-061-3/+53
| | | Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-99518: Fix escape symbol in `test_enum` (#99519)Nikita Sobolev2022-11-161-1/+1
|
* gh-92647: [Enum] use final status to determine lookup or create (GH-99500)Ethan Furman2022-11-151-3/+18
| | | | | | | * use final status to determine lookup or create * 📜🤖 Added by blurb_it. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* gh-99248: [Enum] fix negative number infinite loop (GH-99256)Ethan Furman2022-11-081-1/+15
| | | | | | | | [Enum] fix negative number infinite loop - _iter_bits_lsb() now raises a ValueError if a negative number is passed in - verify() now skips checking negative numbers for named flags
* [Enum] add built-in property to test_test_simple_enum (GH-98453)Ethan Furman2022-11-061-0/+6
|