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

Can't use pytest.mark.parametrize inside unittest class #541

Closed
pytestbot opened this issue Jul 16, 2014 · 3 comments
Closed

Can't use pytest.mark.parametrize inside unittest class #541

pytestbot opened this issue Jul 16, 2014 · 3 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: BitBucket: d3ph, GitHub: d3ph


#!python

def test_parametrize_unittest(testdir):
    testpath = testdir.makepyfile("""
        import unittest
        import pytest
        pytest_plugins = "pytest_unittest"
        class MyTestCase(unittest.TestCase):
            @pytest.mark.parametrize('param', ['foo'])
            def testpassing(self, param):
                self.assertEquals(param, 'foo')
            @pytest.mark.parametrize('param', ['foo'])
            def test_failing(self, param):
                self.assertEquals(param, 'bar')
    """)
    reprec = testdir.inline_run(testpath)
    assert reprec.matchreport("testpassing").passed
    assert reprec.matchreport("test_failing").failed

@pytestbot
Copy link
Contributor Author

pytestbot commented Jul 16, 2014

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


It's not possible to have extra arguments to unittest functions. See the note at the end of https://docs.pytest.org/en/latest/unittest.html .

@sbraz
Copy link

sbraz commented Apr 6, 2020

Hello, why has this issue been closed? It would be a useful feature.

@RonnyPfannschmidt
Copy link
Member

It's not supportable by unittest, so it's not added

Unittest is only supported, not extended

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

3 participants