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
In the pytest using pytest_bdd. When we have several test using scenario outlines. When different scenario outlines have the same examples, then we run targeted test into only one example of a scenario outline using -k filter. Syrupy with JSONSnapshotExtension extension, will think other snapshots with same example from different scenario outlines are unused.
To reproduce
Have tests in bdd format like this:
my_feature.feature
@test1
Scenario Outline: Test1
Then The result is <file_type>
Examples:
| file_type |
| JSON |
| CSV |
@test2
Scenario Outline: Test2
Then The result is <file_type>
Examples:
| file_type |
| JSON |
| CSV |
Implement the test and snapshot using JSONSnapshotExtension extension.
test_feature.py
importpytestfrompytest_bddimportparsers, scenarios, thenfromsyrupy.assertionimportSnapshotAssertionfromsyrupy.extensions.jsonimportJSONSnapshotExtensionscenarios("my_feature.feature")
@pytest.fixturedefcustom_snapshot(snapshot: SnapshotAssertion):
returnsnapshot.use_extension(JSONSnapshotExtension)
@then(parsers.cfparse("The result is {file_type}"))defcheck_the_file_type(file_type: str, custom_snapshot: SnapshotAssertion):
assertfile_type==custom_snapshot
Run the snapshot generation pytest --snapshot-update
Modify Test1 JSON snapshot to fail the test
Run the targeted test only for test 1 JSON example pytest -m 'test1' -k 'JSON'
Observe that the run will suggest unused snapshots for Test2 JSON.
Expected behavior
Snapshot from other test with the same examples are not considered unused.
Screenshots
Environment (please complete the following information):
wsl Ubuntu, Windows 11
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
Describe the bug
In the pytest using pytest_bdd. When we have several test using scenario outlines. When different scenario outlines have the same examples, then we run targeted test into only one example of a scenario outline using -k filter. Syrupy with JSONSnapshotExtension extension, will think other snapshots with same example from different scenario outlines are unused.
To reproduce
my_feature.feature
test_feature.py
pytest --snapshot-update
pytest -m 'test1' -k 'JSON'
Expected behavior
Snapshot from other test with the same examples are not considered unused.
Screenshots
Environment (please complete the following information):
wsl Ubuntu, Windows 11
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
platform linux -- Python 3.10.6, pytest-7.3.2, pluggy-1.2.0
configfile: pytest.ini
plugins: metadata-3.0.0, bdd-6.1.1, allure-pytest-bdd-2.13.2, bdd-html-0.1.14a0, html-3.2.0, syrupy-4.0.6, check-2.1.5
Additional context
The text was updated successfully, but these errors were encountered: