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

No cassette found when test function is args are multiline #1

Closed
pdjohntony opened this issue Mar 21, 2024 · 2 comments
Closed

No cassette found when test function is args are multiline #1

pdjohntony opened this issue Mar 21, 2024 · 2 comments

Comments

@pdjohntony
Copy link
Owner

No cassette is found for the following example:

@pytest.mark.vcr
@pytest.mark.parametrize(
    "field, value",
    [
        ("addressDescription", "Fake Address"),
        ("addressDescription", ""),
        ("name", "Fake Location"),
        ("name", ""),
    ],
)
def test_msteams_service_emergency_location_update_bad_raises(
    mstsc, field, value, emer_addr
):

I think its due to the (args) being multiline. Need to investigate further.

@pdjohntony
Copy link
Owner Author

This issue is actually caused by the @pytest.mark.parametrize() decorator, which will result in multiple cassettes with different file names for a single test. The current code looks for a single cassette with a name that explicitly match the test name.

So the following test:

@pytest.mark.vcr
def test_msteams_service_emergency_location_get(mstsc)

Creates a cassette with the name:

test_msteams_service_emergency_location_get.yaml

But with the @pytest.mark.parametrize() decorator, the following test:

@pytest.mark.vcr
@pytest.mark.parametrize(
    "field, value",
    [
        ("addressDescription", "Fake Address"),
        ("addressDescription", ""),
        ("name", "Fake Location"),
        ("name", ""),
    ],
)
def test_msteams_service_emergency_location_update_bad_raises(
    mstsc, field, value, emer_addr
):

Creates 4 cassettes with the names:

test_msteams_service_emergency_location_update_bad_raises[addressDescription-].yaml
test_msteams_service_emergency_location_update_bad_raises[addressDescription-Fake Address].yaml
test_msteams_service_emergency_location_update_bad_raises[name-].yaml
test_msteams_service_emergency_location_update_bad_raises[name-Fake Location].yaml

I'm working on a fix to search for any number of cassette files that starts with the test name.

pdjohntony referenced this issue Mar 22, 2024
This is working, but produces multiple open and delete code lens buttons. Need to combine multiple cassette actions into single button.

Also the `delete cassettes in current file` command does not locate parametrized cassettes.
@pdjohntony
Copy link
Owner Author

Fixed in 1.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant