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

parametrize fails when values are unhashable #244

Closed
pytestbot opened this issue Dec 26, 2012 · 21 comments
Closed

parametrize fails when values are unhashable #244

pytestbot opened this issue Dec 26, 2012 · 21 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)


seems like a recent change in parametrizing disallows hashable items
this broke the hgdistver testsuite


@pytestbot
Copy link
Contributor Author

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


Can you create a little example?

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


removed, mistake

@pytestbot
Copy link
Contributor Author

Original comment by Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt):


#!python

archival_mapping = {
    '1.0': {'tag': '1.0'},
    '1.2.2a1': {'tag': 'release-1.2.2a1'},
}
import pytest
@pytest.mark.parametrize('expected data'.split(),
                         archival_mapping.items(),
                         archival_mapping)
def test_archival_to_version(expected, data):
    pass

@pytestbot
Copy link
Contributor Author

Original comment by Mark Tsuchida (BitBucket: marktsuchida, GitHub: marktsuchida):


This might not add anything, but I've encountered the same problem with pytest 2.3.4 and Python 3.3.0, using the following example.

#!python

import pytest

@pytest.fixture(params=[[1, 2], [3, 4]])
def myfixture(request): 
    pass

def test_nothing(myfixture):
    pass

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


working on this

@pytestbot
Copy link
Contributor Author

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


@bubenkoff any progress?

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


I mentioned this before, the case worked, so test just passes
test was merged i think

@pytestbot
Copy link
Contributor Author

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


my memory is partially outsourced, didn't you know?

More seriously, someone showed me a failure at PyconDE that looked much like this issue. This reproduces it:

#!python

import pytest

def pytest_generate_tests(metafunc):
    metafunc.parametrize("x", [{},{}], indirect=True)

@pytest.fixture
def x(request):
    return request.param

def test_hello(x):
    assert x

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


here's the PR i did to reproduce
https://bitbucket.org/hpk42/pytest/pull-request/68/parametrize-fails-when-values-are/diff

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


https://bitbucket.org/hpk42/pytest/pull-request/68/parametrize-fails-when-values-are/diff
here's the MR i did to reproduce

@pytestbot
Copy link
Contributor Author

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


it's not using the "indirect" parameter which seems to be the failing case currently.

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


but indirect wasn't mentioned in this issue at all

@pytestbot
Copy link
Contributor Author

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


sure, to be clear, i am not blaming you for anythying. Just noting that there still is an issue that fits under the title. If you can't/don't want to care i can take a look.

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


no, im not trying to quit, i just wasn't aware that it's an issue only when using indirect
actually i even wrote a fix (before running test)
but then i reverted it as test passed anyway :)

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


so in conclusion, then i'll continue on this :)

@pytestbot
Copy link
Contributor Author

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


great :)

@pytestbot
Copy link
Contributor Author

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


@bubenkoff are you still up for the issue? If not please drop a quick note here.

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


sorry, still in todo
will try to finish this week

@pytestbot
Copy link
Contributor Author

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


@bubenkoff can you try to resolve this issue or un-assign yourselve until thursday?

@pytestbot
Copy link
Contributor Author

Original comment by Anatoly Bubenkov (BitBucket: bubenkoff, GitHub: bubenkoff):


https://bitbucket.org/hpk42/pytest/pull-request/88/parametrize-fails-when-values-are/diff closes this

@pytestbot
Copy link
Contributor Author

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


This was fixed by Anatoly and me on trunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant