summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* gh-93464: [Enum] fix auto() failure during multiple assignment (GH-99148)Ethan Furman2022-11-061-0/+44
| | | | | | * fix auto() failure during multiple assignment i.e. `ONE = auto(), 'text'` will now have `ONE' with the value of `(1, 'text')`. Before it would have been `(<an auto instance>, 'text')`
* gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528)Ethan Furman2022-10-051-1/+1
|
* gh-95591: [Enum] use `_FlagTests` base class (GH-96475)Nikita Sobolev2022-09-201-4/+4
|
* gh-95077: [Enum] add code-based deprecation warnings for member.member ↵Ethan Furman2022-07-251-1/+15
| | | | | | | access (GH-95083) * issue deprecation warning for member.member access * always store member property in current class * remove __getattr__
* Revert "gh-93910: [Enum] restore member.member restriction while keeping ↵Ethan Furman2022-07-181-6/+1
| | | | | performance boost (GH-94913)" (#94985) This reverts commit c20186c3972ff38577c4c5e32ca86748210983d2.
* gh-94601: [Enum] fix inheritance for __str__ and friends (GH-94942)Ethan Furman2022-07-181-5/+21
|
* gh-93910: [Enum] restore member.member restriction while keeping performance ↵Ethan Furman2022-07-171-1/+6
| | | | boost (GH-94913)
* gh-93910: Fix enum performance regression (GH-94614)Michael Droettboom2022-07-071-0/+1
| | | | | | | | | | | | | | This removes the performance regression in 3.11, **at the expense of not fixing the "bug" that allows accessing values from values** (e.g. `Color.RED.BLUE`). Using the benchmark @markshannon [presented](https://github.com/python/cpython/issues/93910#issuecomment-1165503032), the results are: | Version | Enum | Fast enum | Normal class | | --- | --- | --- | --- | | 3.10 | 2.04 | 0.59 | 0.56 | | 3.11 | 2.78 | 0.31 | 0.15 | | This PR | 1.30 | 0.32 | 0.16 | I share this mostly as information about the source of the regression, as this may be useful. It may be that the lower-risk approach for the beta is just to revert to a previously-known working state.
* gh-94318: Strip trailing spaces in pydoc text output (GH-94319)Serhiy Storchaka2022-06-271-27/+27
|
* gh-93820: Pickle enum.Flag by name (GH-93891)Serhiy Storchaka2022-06-261-2/+42
|
* [Enum] Remove automatic docstring generation (GH-94188)Sam Ezeh2022-06-231-162/+4
|
* gh-91456: [Enum] Deprecate default auto() behavior with mixed value types ↵Oscar R2022-06-231-9/+56
| | | | | | | (GH-91457) When used with plain Enum, auto() returns the last numeric value assigned, skipping any incompatible member values (such as strings); starting in 3.13 the default auto() for plain Enums will require all the values to be of compatible types, and will return a new value that is 1 higher than any existing value. Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-88123: Implement new Enum __contains__ (GH-93298)Carl Bordum Hansen2022-06-221-94/+69
| | | Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* gh-93847: Fix repr of enum of generic aliases (GH-93885)Serhiy Storchaka2022-06-161-0/+10
|
* gh-93820: Fix copy() regression in enum.Flag (GH-93876)Christian Heimes2022-06-161-0/+28
| | | | | | | | GH-26658 introduced a regression in copy / pickle protocol for combined `enum.Flag`s. `copy.copy(re.A | re.I)` would fail with `AttributeError: ASCII|IGNORECASE`. `enum.Flag` now has a `__reduce_ex__()` method that reduces flags by combined value, not by combined name.
* gh-93250: [Enum] Change IntEnum boundary to KEEP for backwards compatibility ↵Ethan Furman2022-05-271-2/+10
| | | | | (GH-93302) In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior.
* gh93107: [Enum] fix missing variable in global_str (GH-93107)Ethan Furman2022-05-231-0/+11
|
* Update CPyhton configuration for 3.12 (#92451)Dong-hee Na2022-05-081-0/+6
| | | | | | | * Update CPyhton configuration for 3.12 * Fix PC/pyconfig.h * Add expect failure
* gh-78157: [Enum] nested classes will not be members in 3.13 (GH-92366)Ethan Furman2022-05-061-0/+141
| | | | | | | - add member() and nonmember() functions - add deprecation warning for internal classes in enums not becoming members in 3.13 Co-authored-by: edwardcwang
* bpo-40280: Detect missing threading on WASM platforms (GH-32352)Christian Heimes2022-04-071-0/+2
| | | Co-authored-by: Brett Cannon <brett@python.org>
* bpo-46198: rename duplicate tests and remove unused code (GH-30297)Nikita Sobolev2022-03-101-1/+1
|
* bpo-46477: [Enum] ensure Flag subclasses have correct bitwise methods (GH-30816)Ethan Furman2022-01-231-0/+7
|
* bpo-45535: [Enum] include special dunders in dir() (GH-30677)Ethan Furman2022-01-181-24/+29
| | | | | | | | | Include the `__dunders__` in `dir()` that make `Enum` special: - `__contains__` - `__getitem__` - `__iter__` - `__len__` - `__members__`
* bpo-46418: [Enum] simplify `MODULE` declaration in tests (GH-30647)Nikita Sobolev2022-01-171-1/+1
|
* bpo-40066: [Enum] skip failing doc test (GH-30637)Kumar Aditya2022-01-171-1505/+1359
|
* Revert "bpo-40066: [Enum] update str() and format() output (GH-30582)" ↵Victor Stinner2022-01-171-1359/+1505
| | | | | (GH-30632) This reverts commit acf7403f9baea3ae1119fc6b4a3298522188bf96.
* bpo-40066: [Enum] update str() and format() output (GH-30582)Ethan Furman2022-01-161-1505/+1359
| | | | | | | | | | | | | | | Undo rejected PEP-663 changes: - restore `repr()` to its 3.10 status - restore `str()` to its 3.10 status New changes: - `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result - zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'` - update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type - added `_numeric_repr_` to `Flag` to control display of unnamed values - enums without doc strings have a more comprehensive doc string added - `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
* bpo-46242: [Enum] better error message for extending `Enum` with members ↵Nikita Sobolev2022-01-141-0/+2
| | | | (GH-30357)
* bpo-46327: [Enum] remove skipped tests (GH-30512)Nikita Sobolev2022-01-101-11/+0
|