You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.rst
+2
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Added
14
14
15
15
Changed
16
16
+++++++
17
+
* Step arguments ``"datatable"`` and ``"docstring"`` are now reserved, and they can't be used as step argument names.
17
18
18
19
Deprecated
19
20
++++++++++
@@ -24,6 +25,7 @@ Removed
24
25
Fixed
25
26
+++++
26
27
* Fixed an issue with the upcoming pytest release related to the use of ``@pytest.mark.usefixtures`` with an empty list.
28
+
* Render template variables in docstrings and datatable cells with example table entries, as we already do for steps definitions.
27
29
* Address many ``mypy`` warnings. The following private attributes are not available anymore (`#658 <https://github.com/pytest-dev/pytest-bdd/pull/658>`_):
28
30
* ``_pytest.reports.TestReport.scenario`` (replaced by ``pytest_bdd.reporting.test_report_context`` WeakKeyDictionary)
29
31
* ``__scenario__`` attribute of test functions generated by the ``@scenario`` (and ``@scenarios``) decorator (replaced by ``pytest_bdd.scenario.scenario_wrapper_template_registry`` WeakKeyDictionary)
Copy file name to clipboardExpand all lines: README.rst
+52
Original file line number
Diff line number
Diff line change
@@ -513,6 +513,58 @@ Example:
513
513
defshould_have_left_cucumbers(cucumbers, left):
514
514
assert cucumbers["start"] - cucumbers["eat"] == left
515
515
516
+
517
+
Example parameters from example tables can not only be used in steps, but also embedded directly within docstrings and datatables, allowing for dynamic substitution.
518
+
This provides added flexibility for scenarios that require complex setups or validations.
519
+
520
+
Example:
521
+
522
+
.. code-block:: gherkin
523
+
524
+
# content of docstring_and_datatable_with_params.feature
525
+
526
+
Feature: Docstring and Datatable with example parameters
527
+
Scenario Outline: Using parameters in docstrings and datatables
528
+
Given the following configuration:
529
+
"""
530
+
username: <username>
531
+
password: <password>
532
+
"""
533
+
When the user logs in
534
+
Then the response should contain:
535
+
| field | value |
536
+
| username | <username> |
537
+
| logged_in | true |
538
+
539
+
Examples:
540
+
| username | password |
541
+
| user1 | pass123 |
542
+
| user2 | 123secure |
543
+
544
+
.. code-block:: python
545
+
546
+
from pytest_bdd import scenarios, given, when, then
0 commit comments