Skip to content

Commit 406e16c

Browse files
author
Sylvain MARIE
committed
2.0.0 changelog
1 parent a708fbe commit 406e16c

File tree

1 file changed

+43
-26
lines changed

1 file changed

+43
-26
lines changed

docs/changelog.md

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,83 @@
11
# Changelog
22

3-
### 2.0.0 - Less boilerplate & full `pytest` alignment !
3+
### 2.0.0 - Less boilerplate & full `pytest` alignment
44

5-
**Case functions**
5+
I am very pleased to announce this new version of `pytest-cases`, providing a lot of **major** improvements. Creating powerful and complex test suites have never been so easy and intuitive !
66

7-
- New `@case(id=None, tags=(), marks=())` decorator to replace `@case_name`, `@case_tags` and `@test_target` (all deprecated): a single simple way to customize all aspects of a case function. Also, `target` disappears from the picture as it was just a tag like others - this could be misleading.
7+
Below is a complete list of changes, but the user guide has also been updated accordingly so feel free to [have a look](index.md) to get a complete example-based walkthrough.
88

9-
- `@cases_generator` is now deprecated and replaced with `@parametrize` : now, cases can be parametrized exactly the same way than tests. This includes the ability to put marks on the whole or on some specific parameter values. `@parametrize_plus` has been renamed `@parametrize` for readability. It was also improved in order to support the alternate parametrization mode that was previously offered by `@cases_generator`. That way, users will be able to choose the style of their choice. Fixes [#57](https://github.com/smarie/python-pytest-cases/issues/57) and [#106](https://github.com/smarie/python-pytest-cases/issues/106).
10-
11-
- Since `@cases_generat`Marks can now
12-
13-
- Now case functions can require fixtures ! In that case they will be transformed into fixtures and injected as `fixture_ref` in the parametrization. Fixes [#56](https://github.com/smarie/python-pytest-cases/issues/56).
149

10+
**A/ More powerful and flexible cases collection**
1511

16-
**Test functions**
12+
New [`@parametrize_with_cases`](./api_reference.md#parametrize_with_cases) decorator to replace `@cases_data` (deprecated).
1713

18-
New `@parametrize_with_cases(argnames, cases, ...)` decorator to replace `@cases_data` (deprecated):
19-
20-
- Aligned with `pytest` behaviour:
14+
1. Aligned with `pytest`:
2115

22-
- now `argnames` can contain several names, and the cases are unpacked automatically. **Less boilerplate code**: no need to perform a `case.get()` in the test anymore !
16+
- now `argnames` can contain several names, and the case functions are **automatically unpacked** into it. You don't need to perform a `case.get()` in the test anymore !
2317

2418
@parametrize_with_cases("a,b")
2519
def test_foo(a, b):
2620
# use a and b directly !
2721
...
2822

29-
3023
- cases are unpacked at test *setup* time, so *the clock does not run while the case is created* - in case you use `pytest-harvest` to collect the timings.
3124

3225
- `@parametrize_with_cases` can be used on test functions *as well as fixture functions* (it was already the case in v1)
3326

3427

35-
- **A single `cases` argument** to indicate the cases, wherever they come from:
28+
2. Easier to configure:
29+
30+
- the decorator now has a single `cases` argument to indicate the cases, wherever they come from (no `module` argument anymore)
3631

37-
- Default (`cases=AUTO`) *automatically looks for cases in the associated case module* named `test_xxx_cases.py`. Users can easily switch to alternate pattern `cases_xxx.py` with `cases=AUTO2`. Fixes [#91](https://github.com/smarie/python-pytest-cases/issues/91).
32+
- default (`cases=AUTO`) *automatically looks for cases in the associated case module* named `test_xxx_cases.py`. Users can easily switch to alternate pattern `cases_xxx.py` with `cases=AUTO2`. Fixes [#91](https://github.com/smarie/python-pytest-cases/issues/91).
3833

39-
- *Cases can sit inside a class*, which makes it much more convenient to organize when they sit in the same file than the tests. Fixes [#93](https://github.com/smarie/python-pytest-cases/issues/93).
34+
- **cases can sit inside a class**, like [what you're used to do with `pytest`](https://docs.pytest.org/en/stable/getting-started.html#group-multiple-tests-in-a-class). This additional style makes it much more convenient to organize cases and associated them with tests, when cases sit in the same file than the tests. Fixes [#93](https://github.com/smarie/python-pytest-cases/issues/93).
4035

4136
- an explicit sequence can be provided, *it can mix all kind of sources*: functions, classes, modules, and *module names as strings* (even relative ones!).
4237

4338
@parametrize_with_cases("a", cases=(CasesClass, '.my_extra_cases'))
4439
def test_foo(a):
4540
...
4641

47-
**Misc / pytest goodies**
4842

49-
- `parametrize_plus` now raises an explicit error message when the user makes a mistake with the argnames. Fixes [#105](https://github.com/smarie/python-pytest-cases/issues/105).
43+
3. More powerful API for filtering:
5044

51-
- `parametrize_plus` now provides an alternate way to pass argnames, argvalues and ids. Fixes [#106](https://github.com/smarie/python-pytest-cases/issues/106).
45+
- a new `prefix` argument (default `case_`) can be used to define case functions for various type of parameters: welcome `user_<id>`, `data_<id>`, `algo_<id>`, `model_<id>` ! Fixes [#108](https://github.com/smarie/python-pytest-cases/issues/108)
46+
47+
- a new `glob` argument receiving a glob-like string can be used to further filter cases based on their names. For example you can distinguish `*_success` from `*_failure` case ids, so as to dispatch them to the appropriate positive or negative test. Fixes [#108](https://github.com/smarie/python-pytest-cases/issues/108)
48+
49+
- finally you can still use `has_tag` and/or provide a `filter` callable, but now the callable will receive the case function, and this case function has a `f._pytestcase` attribute containing the id, tags and marks - it is therefore much easier to implement custom filtering.
5250

53-
- New aliases for readability: `fixture` for `fixture_plus`, and`parametrize` for `parametrize_plus` (both aliases will coexist with the old names). Fixes [#107](https://github.com/smarie/python-pytest-cases/issues/107).
5451

55-
- New pytest goodie `assert_exception` that can be used as a context manager. Fixes [#104](https://github.com/smarie/python-pytest-cases/issues/104).
56-
57-
- More readable error messages when `lazy_value` does not return the same number of argvalues than expected by the `parametrize`.
58-
59-
- Any error message associated to a `lazy_value` function call is not caught and hidden anymore but is emitted to the user.
52+
**B/ Easier-to-define case functions**
53+
54+
- Case functions can start with different prefixes to denote different kind of data: e.g. `data_<id>`, `user_<id>`, `model_<id>`, etc.
55+
56+
- Case functions can now be parametrized with [`@parametrize`](pytest_goodies.md#parametrize) or `@pytest.mark.parametrize`, just as in pytest ! This includes the ability to put [`pytest` marks](https://docs.pytest.org/en/stable/mark.html) on the whole case, or on some specific parameter values using [`pytest.param`](https://docs.pytest.org/en/stable/example/parametrize.html#set-marks-or-test-id-for-individual-parametrized-test). `@cases_generator` is therefore now deprecated but its alternate style for ids and arguments definition was preserved in `@parametrize`, see below.
57+
58+
- Now case functions can require fixtures ! In that case they will be transformed into fixtures and injected as `fixture_ref` in the parametrization. Fixes [#56](https://github.com/smarie/python-pytest-cases/issues/56).
59+
60+
- New single optional `@case(id=None, tags=(), marks=())` decorator to replace `@case_name` and `@case_tags` (deprecated): a single simple way to customize all aspects of a case function. Also, `@test_target` completely disappears from the picture as it was just a tag like others - this could be misleading.
61+
62+
63+
**C/ Misc / pytest goodies**
64+
65+
- New aliases for readability: `@fixture` for `@fixture_plus`, and`@parametrize` for `@parametrize_plus` (both aliases will coexist with the old names). Fixes [#107](https://github.com/smarie/python-pytest-cases/issues/107).
66+
67+
- `@parametrize` was improved in order to support the alternate parametrization mode that was previously offered by `@cases_generator`, see [api reference](api_reference.md#parametrize). That way, users will be able to choose the style of their choice. Fixes [#57](https://github.com/smarie/python-pytest-cases/issues/57) and [#106](https://github.com/smarie/python-pytest-cases/issues/106).
68+
69+
- `@parametrize` now raises an explicit error message when the user makes a mistake with the argnames. Fixes [#105](https://github.com/smarie/python-pytest-cases/issues/105).
70+
71+
- More readable error messages in `@parametrize` when `lazy_value` does not return the same number of argvalues than expected from the argnames.
72+
73+
- Any error message associated to a `lazy_value` function call is not caught and hidden anymore but is emitted to the user, for easier debugging.
6074

6175
- Fixed issue with `lazy_value` when a single mark is passed in the constructor.
6276

6377
- `lazy_value` used as a tuple for several arguments now have a correct id generated even in old pytest version 2.
78+
79+
- New pytest goodie `assert_exception` that can be used as a context manager. Fixes [#104](https://github.com/smarie/python-pytest-cases/issues/104).
80+
6481

6582
### 1.17.0 - `lazy_value` improvements + annoying warnings suppression
6683

0 commit comments

Comments
 (0)