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

Failing to parameterize leaves metafunc unparameterized, resulting in error #197

Closed
pytestbot opened this issue Oct 4, 2012 · 2 comments
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jason R. Coombs (BitBucket: jaraco, GitHub: jaraco)


We have a test where we often want to run it against a varying number of parameters (pulled from a live environment):

@pytest.mark.parametrize(('region', 'name'),
    list(questionnaires_under_test()))
def test_questionnaire(region, name):
    ...

The function 'questionnaires_under_test' could generate 0 or more results. If it generates 0 results, simulated by this code:

@pytest.mark.parametrize(('region', 'name'), [])
def test_questionnaire(region, name):
    ...

however, the test fails with this error:

        LookupError: no factory found for argument 'region'
        available funcargs: pytestconfig, selenium, recwarn, pony_survey, monkeypatch, simple_survey, capfd, pdl_gender_survey, capsys, tmpdir
        use 'py.test --funcargs [testpath]' for help on them.

Since pytest has already had the opportunity to parameterize that function, but nothing was suitable, it would be nice if pytest could remove that test from the tests to be run and not raise the error.

I've been able to work around the issue by skipping the entire file if no questionnaires would be generated:

if not pytest.config.option.live_questionnaires:
    pytest.skip()

Another way to describe this issue, pytest allows for parameterization of 1 or more inputs, but doesn't handle 0 or more very well. It's conceivable to me that pytest could handle the null case without raising an error. If that's the case, please consider it for a future improvement.

I realize there might be some complications in how parameterization works that would make this a challenging improvement. If that's the case, it's probably not worth it.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


I agree that the null case should be handled, maybe a skip result is most fitting. "deselected" might be the alternative.

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue197 - in case a function is parametrized with zero arguments,
skip it during setup

@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
Neovim uses stdout for `msgpack` communication and the `subprocess` call for `virtualenv` was leaking that stream. Fix is to attach to a `subprocess.PIPE`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

1 participant