Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-bdd: attachments are cloned in the step and in the test #474

Closed
nyermolenko-eis opened this issue Feb 24, 2020 · 1 comment · May be fixed by #550
Closed

pytest-bdd: attachments are cloned in the step and in the test #474

nyermolenko-eis opened this issue Feb 24, 2020 · 1 comment · May be fixed by #550

Comments

@nyermolenko-eis
Copy link

image

Attachment is set up in the scope of the method only (but it's a fixture)'
image

@sseliverstov sseliverstov added theme:pytest-bdd bug Something isn't working labels Jun 2, 2020
Duisus pushed a commit to Duisus/allure-python that referenced this issue Jan 9, 2021
Add file attachment_worker.py with AttachmentWorker class

Now PytestBDDListener use AttachmentWorker for deleting duplicate of attachments
Duisus pushed a commit to Duisus/allure-python that referenced this issue Jan 9, 2021
Duisus pushed a commit to Duisus/allure-python that referenced this issue Jan 12, 2021
Duisus pushed a commit to Duisus/allure-python that referenced this issue Jan 12, 2021
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
Add file attachment_worker.py with AttachmentWorker class

Now PytestBDDListener use AttachmentWorker for deleting duplicate of attachments
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
Duisus added a commit to Duisus/allure-python that referenced this issue Jan 24, 2021
@delatrie
Copy link
Contributor

Hi, @nyermolenko-eis !

If you need to pass the result of a step into another step, use target_fixture instead:

@when("user calls GetQuery API endpoint", target_fixture="api_response")
def api_response():
    response = ...
    allure.attach("Text", "attachment-1", AttachmentType.TEXT)
    return response

@then("response is ok")
def validate_response(api_response):
    ...

Otherwise, it is expected for a fixture to be called before each test function where it is required, applying all the associated side effects during each call. Trying to revert those side effects (allure.attach is just one of them) is clearly a dead-end to me.

I will hold this issue opened for a week or two. If you cannot use target_fixture for some reason, please, provide more details about your scenario. Otherwise, you can close the issue and the pull request by yourself (or I will close them later if no feedback is given).

@delatrie delatrie removed the bug Something isn't working label Dec 22, 2022
@delatrie delatrie closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants