Skip to content

Commit 9d7fe5f

Browse files
committed
UG: Document IntEnum and IntFlag conversion (robotframework#3910)
1 parent f42d982 commit 9d7fe5f

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

‎doc/userguide/src/ExtendingRobotFramework/CreatingTestLibraries.rst‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,14 +1484,24 @@ Other types cause conversion failures.
14841484
| | | | | `time as time string`_ or `time as "timer" string`_. Integers | | `01:02` (same as above) |
14851485
| | | | | and floats are considered to be seconds. | |
14861486
+-------------+---------------+------------+--------------+----------------------------------------------------------------+--------------------------------------+
1487-
| Enum_ | | | string | The specified type must be an enumeration (a subclass of | .. sourcecode:: python |
1488-
| | | | | Enum_) and given arguments must match its members. | |
1489-
| | | | | | class Color(Enum): |
1490-
| | | | | Starting from RF 3.2.2, matching members is case-, space- | GREEN = 1 |
1491-
| | | | | and underscore-insensitive. | DARK_GREEN = 2 |
1487+
| Enum_ | | | string | The specified type must be an enumeration (a subclass of Enum_ | .. sourcecode:: python |
1488+
| | | | | or Flag_) and given arguments must match its member names. | |
1489+
| | | | | | class Direction(Enum): |
1490+
| | | | | Starting from RF 3.2.2, matching member names is case-, space- | NORTH = auto() |
1491+
| | | | | and underscore-insensitive. | NORTH_WEST = auto() |
14921492
| | | | | | |
1493-
| | | | | | | `GREEN` (Color.GREEN) |
1494-
| | | | | | | `Dark Green` (Color.DARK_GREEN) |
1493+
| | | | | | | `NORTH` (Direction.NORTH) |
1494+
| | | | | | | `north west` (Direction.NORTH_WEST)|
1495+
+-------------+---------------+------------+--------------+----------------------------------------------------------------+--------------------------------------+
1496+
| IntEnum_ | | | string, int | The specified type must be an integer based enumeration (a | .. sourcecode:: python |
1497+
| | | | | subclass of IntEnum_ or IntFlag_) and given arguments must | |
1498+
| | | | | match its member names or values. | class PowerState(IntEnum): |
1499+
| | | | | | OFF = 0 |
1500+
| | | | | Matching member names is case-, space- and | ON = 1 |
1501+
| | | | | and underscore-insensitive. Values can be given as actual | |
1502+
| | | | | integers and as strings that can be converted to integers. | | `OFF` (PowerState.OFF) |
1503+
| | | | | | | `1` (PowerState.ON) |
1504+
| | | | | Support for IntEnum_ and IntFlag_ is new in RF 4.1. | |
14951505
+-------------+---------------+------------+--------------+----------------------------------------------------------------+--------------------------------------+
14961506
| None_ | | NoneType | string | String `NONE` (case-insensitively) is converted to `None` | | `None` |
14971507
| | | | | object. Other values cause an error. | |
@@ -1533,6 +1543,9 @@ Other types cause conversion failures.
15331543
.. _date: https://docs.python.org/library/datetime.html#datetime.date
15341544
.. _timedelta: https://docs.python.org/library/datetime.html#datetime.timedelta
15351545
.. _Enum: https://docs.python.org/library/enum.html#enum.Enum
1546+
.. _Flag: https://docs.python.org/library/enum.html#enum.Flag
1547+
.. _IntEnum: https://docs.python.org/library/enum.html#enum.IntEnum
1548+
.. _IntFlag: https://docs.python.org/library/enum.html#enum.IntFlag
15361549
.. _None: https://docs.python.org/library/constants.html#None
15371550
.. _list: https://docs.python.org/library/stdtypes.html#list
15381551
.. _Sequence: https://docs.python.org/library/collections.abc.html#collections.abc.Sequence

0 commit comments

Comments
 (0)