tophat / syrupy

:pancakes: The sweeter pytest snapshot plugin
https://tophat.github.io/syrupy
Apache License 2.0
485 stars 33 forks source link

SyntaxError: invalid syntax on pytest --snapshot-update #844

Open alexjolig opened 5 months ago

alexjolig commented 5 months ago

I just installed syrupy and tried pytest --snapshot-update to produce the snapshots. at the first test including the snapshot fixture, I have this line: base_url = "some-url" and I get this error:

E       pytest --snapshot-update    base_url = "some-url"
E                                   ^
E   SyntaxError: invalid syntax

How to reproduce?

Add this test:

def test_get_current_user(get_headers, snapshot):
    base_url = "some-url"
    response = requests.get(
        f"https://{base_url}/api/account_manager/user/me",
        headers={**get_headers, "Content-Type": "application/json"},
    )
    result = response.json()
    assert response.status_code == 200
    assert result == snapshot

run: pytest --snapshot-update

Environment:

noahnu commented 5 months ago

I don't think this is related to syrupy. This looks like you probably have a mismatched whitespace causing a syntax error. If you can create a GitHub repo that reproduces the error outside of your local environment, I can take a look. As it stands, I can't reproduce this from the snippet you shared.