Skip to content

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

Closed

Description

@smarie

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)

Activity

  1. 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[/+] on May 21, 2021
  2. smarie commented on May 21, 2021

    @smarie
    OwnerAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions