Skip to content

Commit f8d03b2

Browse files
author
Sylvain MARIE
committed
Updated api reference and docstrings for get_current_cases and current_cases
1 parent 09f78ff commit f8d03b2

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

docs/api_reference.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ In general, using `help(symbol)` is the recommended way to get the latest docume
88

99
A fixture containing [`get_current_cases(request)`](#get_current_cases).
1010

11-
This is a dictionary containing all case parameters for the currently active `pytest` item. For each test function argument parametrized using a [`@parametrize_with_case(<argname>, ...)`](#parametrize_with_cases) this dictionary contains an entry `{<argname>: (actual_id, case_function)}`. If several argnames are parametrized this way, a dedicated entry will be present for each argname.
11+
This is a dictionary containing all case parameters for the currently active `pytest` item. For each test function argument parametrized using a [`@parametrize_with_case(<argname>, ...)`](#parametrize_with_cases) this dictionary contains an entry `{<argname>: (case_id, case_function, case_params)}`. If several argnames are parametrized this way, a dedicated entry will be present for each argname. The tuple is a `namedtuple` containing
12+
13+
- `id` a string containing the actual case id constructed by `@parametrize_with_cases`.
14+
- `function` the original case function.
15+
- `params` a dictionary, containing the parameters of the case, if itself is parametrized. Note that if the
16+
case is parametrized with `@parametrize_with_cases`, the associated parameter value in the dictionary will also be
17+
`(case_id, case_function, case_params)`.
1218

13-
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where `<dct>` is a dictionary `{<argname>: (actual_id, case_function)}`.
19+
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where `<dct>` is a dictionary `{<argname>: (case_id, case_function, case_params)}`.
1420

15-
To get more information on a case function, you can use [`get_case_id(f)`](#get_case_id), [`get_case_marks(f)`](#get_case_marks), [`get_case_tags(f)`](#get_case_tags). You can also use [`matches_tag_query`](#matches_tag_query) to check if a case function matches some expectations either concerning its id
21+
To get more information on a case function, you can use [`get_case_marks(f)`](#get_case_marks), [`get_case_tags(f)`](#get_case_tags). You can also use [`matches_tag_query`](#matches_tag_query) to check if a case function matches some expectations either concerning its id
1622
or its tags. See [filters and tags documentation](https://smarie.github.io/python-pytest-cases/#filters-and-tags).
1723

1824
## 2 - Case functions
@@ -311,9 +317,15 @@ def get_current_cases(request_or_item):
311317

312318
Returns a dictionary containing all case parameters for the currently active `pytest` item. You can either pass the `pytest` item (available in some hooks) or the `request` (available in hooks, and also directly as a fixture).
313319

314-
For each test function argument parametrized using a [`@parametrize_with_case(<argname>, ...)`](#parametrize_with_cases) this dictionary contains an entry `{<argname>: (actual_id, case_function)}`. If several argnames are parametrized this way, a dedicated entry will be present for each argname.
320+
For each test function argument parametrized using a [`@parametrize_with_case(<argname>, ...)`](#parametrize_with_cases) this dictionary contains an entry `{<argname>: (case_id, case_function, case_params)}`. If several argnames are parametrized this way, a dedicated entry will be present for each argname. The tuple is a `namedtuple` containing
321+
322+
- `id` a string containing the actual case id constructed by `@parametrize_with_cases`.
323+
- `function` the original case function.
324+
- `params` a dictionary, containing the parameters of the case, if itself is parametrized. Note that if the
325+
case is parametrized with `@parametrize_with_cases`, the associated parameter value in the dictionary will also be
326+
`(case_id, case_function, case_params)`.
315327

316-
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where `<dct>` is a dictionary `{<argname>: (actual_id, case_function)}`.
328+
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where `<dct>` is a dictionary `{<argname>: (case_id, case_function, case_params)}`.
317329

318330
To get more information on a case function, you can use [`get_case_id(f)`](#get_case_id), [`get_case_marks(f)`](#get_case_marks), [`get_case_tags(f)`](#get_case_tags). You can also use [`matches_tag_query`](#matches_tag_query) to check if a case function matches some expectations either concerning its id
319331
or its tags. See [filters and tags documentation](https://smarie.github.io/python-pytest-cases/#filters-and-tags).

pytest_cases/case_parametrizer_new.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,13 +1017,19 @@ def get_current_cases(request_or_item):
10171017
directly as a fixture).
10181018
10191019
For each test function argument parametrized using a `@parametrize_with_case(<argname>, ...)` this dictionary
1020-
contains an entry `{<argname>: (actual_id, case_function)}`. If several argnames are parametrized this way,
1021-
a dedicated entry will be present for each argname.
1020+
contains an entry `{<argname>: (case_id, case_function, case_params)}`. If several argnames are parametrized this
1021+
way, a dedicated entry will be present for each argname. The tuple is a `namedtuple` containing
1022+
1023+
- `id` a string containing the actual case id constructed by `@parametrize_with_cases`.
1024+
- `function` the original case function.
1025+
- `params` a dictionary, containing the parameters of the case, if itself is parametrized. Note that if the
1026+
case is parametrized with `@parametrize_with_cases`, the associated parameter value in the dictionary will also be
1027+
`(actual_id, case_function, case_params)`.
10221028
10231029
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where
1024-
`<dct>` is a dictionary `{<argname>: (actual_id, case_function)}`.
1030+
`<dct>` is a dictionary `{<argname>: (case_id, case_function, case_params)}`.
10251031
1026-
To get more information on a case function, you can use `get_case_id(f)`, `get_case_marks(f)`, `get_case_tags(f)`.
1032+
To get more information on a case function, you can use `get_case_marks(f)`, `get_case_tags(f)`.
10271033
You can also use `matches_tag_query` to check if a case function matches some expectations either concerning its id
10281034
or its tags. See https://smarie.github.io/python-pytest-cases/#filters-and-tags
10291035

pytest_cases/plugin.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,13 +1470,19 @@ def current_cases(request):
14701470
14711471
This is a dictionary containing all case parameters for the currently active `pytest` item.
14721472
For each test function argument parametrized using a `@parametrize_with_case(<argname>, ...)` this dictionary
1473-
contains an entry `{<argname>: (actual_id, case_function)}`. If several argnames are parametrized this way,
1474-
a dedicated entry will be present for each argname.
1473+
contains an entry `{<argname>: (case_id, case_function, case_params)}`. If several argnames are parametrized this
1474+
way, a dedicated entry will be present for each argname. The tuple is a `namedtuple` containing
1475+
1476+
- `id` a string containing the actual case id constructed by `@parametrize_with_cases`.
1477+
- `function` the original case function.
1478+
- `params` a dictionary, containing the parameters of the case, if itself is parametrized. Note that if the
1479+
case is parametrized with `@parametrize_with_cases`, the associated parameter value in the dictionary will also be
1480+
`(actual_id, case_function, case_params)`.
14751481
14761482
If a fixture parametrized with cases is active, the dictionary will contain an entry `{<fixturename>: <dct>}` where
1477-
`<dct>` is a dictionary `{<argname>: (actual_id, case_function)}`.
1483+
`<dct>` is a dictionary `{<argname>: (case_id, case_function, case_params)}`.
14781484
1479-
To get more information on a case function, you can use `get_case_id(f)`, `get_case_marks(f)`, `get_case_tags(f)`.
1485+
To get more information on a case function, you can use `get_case_marks(f)`, `get_case_tags(f)`.
14801486
You can also use `matches_tag_query` to check if a case function matches some expectations either concerning its id
14811487
or its tags. See https://smarie.github.io/python-pytest-cases/#filters-and-tags
14821488
"""

0 commit comments

Comments
 (0)