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

"@" syntax to read in tests from files doesn't seem to work for parameterized files #12735

Closed
patrickvonplaten opened this issue Aug 23, 2024 · 1 comment

Comments

@patrickvonplaten
Copy link

patrickvonplaten commented Aug 23, 2024

The "@" functionality doesn't seem to work for parameterized tests

The read-in-tests-from-file functionality as shown here: #12085 doesn't seem to work for parameterized tests.

Repro

tests.py file

Write the following in a test.py file:

# test_add.py
import pytest

# add.py
def add(a, b):
    return a + b

@pytest.mark.parametrize("a, b, expected", [
    (1, 2, 3),
    (0, 0, 0),
    (-1, 1, 0),
    (10, 20, 30),
    (1.5, 2.5, 4.0),
])
def test_add(a, b, expected):
    assert add(a, b) == expected

tests.txt file

Now write a couple of tests in a tests.txt file:

test.py::test_add[1-2-3]
test.py::test_add[0-0-0]

Result

Now try:

pytest @tests.txt

Update - never mind everything works just fine

@patrickvonplaten
Copy link
Author

Sorry I made a typo everything works just fine - thanks for the nice new feature!

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