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

Bug in current_cases fixture: missing case function or case function not the original one #212

Closed
smarie opened this issue May 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@smarie
Copy link
Owner

smarie commented May 21, 2021

Found while working on #211 👍

class MyClassName2:
    def case_bar(self):
        return "barval"

    @parametrize(dummy=['a'])
    def case_foo(self, dummy):
        return "fooval"


@parametrize_with_cases('val', cases=MyClassName2)
def test_function2(val, current_cases):
    ref = {
        "barval": MyClassName2.case_bar,
        "fooval": MyClassName2.case_foo
    }

    case_id, case_func = current_cases['val']
    assert case_id == val[:3]
    assert case_func is ref[val]

Raises a KeyError for the first case (bar)

@smarie smarie added the bug Something isn't working label May 21, 2021
@smarie smarie changed the title Bug in current_cases fixture: missing case function Bug in current_cases fixture: missing case function or case function not the original one May 21, 2021
@smarie
Copy link
Owner Author

smarie commented May 21, 2021

Another issue:

from pytest_cases import parametrize, parametrize_with_cases


class MyClassName:
    def case_foo(self):
        return "fooval"


@parametrize_with_cases('val', cases=MyClassName)
def test_function(val, current_cases):
    assert val == "fooval"

    case_id, case_func = current_cases['val']
    assert case_id == "foo"
    assert case_func is MyClassName.case_foo

raises an AssertionError because case_func is a partial and not the original class function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant