-
Notifications
You must be signed in to change notification settings - Fork 39
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
cases_generator doesn't work with parametrize_with_cases #124
Comments
I @saroad2 thanks for spotting this ! Indeed |
Thank you mate for the quick response! I think it doesn't warn that So my next question is: what is the alternative for What should I use instead of |
Yes, I'll add the deprecation warning. So the conclusion is that This is how you do the same with the new API : from pytest_cases import parametrize, parametrize_with_cases
@parametrize(i=range(3), idgen="i=={i}")
def case_i(i):
return i + 1
@parametrize_with_cases(argnames="j", cases='.')
def test_me(j):
assert j > 0 As you can see the difference is that there is no specific decorator for cases any more: cases can be parametrized with the same decorators than normal import pytest
from pytest_cases import parametrize, parametrize_with_cases
@parametrize(i=range(2), idgen="i=={i}")
def case_i(i):
return i + 1
@pytest.mark.parametrize('i', range(2), ids="i=={}".format)
def case_k(i):
return i + 1
@parametrize_with_cases(argnames="j", cases='.')
def test_me(j):
assert j > 0
def test_synthesis(module_results_dct):
assert list(module_results_dct) == [
'test_me[i-i==0]',
'test_me[i-i==1]',
'test_me[k-i==0]',
'test_me[k-i==1]',
] Let me know if this works for you EDIT: oh, also you can see above that there is a more concise way to indicate "this module", since now relative module names can be used ; simply use |
(closed automatically from commit message for 2.1.3 release but of course feel free to reopen if the above does not work for you) |
As of the latest version,
cases_data
is deprecated and the user is instructed to replace it withparametrize_with_cases
.I tried to replace it as instructed, and got a weird error. A little digging showed me that the problem is that
parametrize_with_cases
doesn't play nice withcases_generator
.Here is a simple example:
Assume I have the following code:
If I want to replace
cases_data
withparametrize_with_cases
, it should look like this:Even though those tests should fail, the error I'm getting is:
Is
cases_generator
deprecated too? If it is, what should I use instead? If it doesn't, it's a bug :)The text was updated successfully, but these errors were encountered: