Skip to content

parametrize ignores marks if parameters are symbols #2176

Closed
@TristenHayfield

Description

@TristenHayfield

@pytest.mark.parameterize does not evaluate marks if parameters are symbols.
Here's an example:

import pytest


@pytest.mark.parametrize('v', [pytest.mark.alpha(0), pytest.mark.bravo(1)])
def test_bug(v):
    pass


def babby():
    pass

@pytest.mark.parametrize('v', [pytest.mark.alpha(babby), pytest.mark.bravo(babby)], ids=['alpha', 'bravo'])
def test_symbug(v):
    pass
$ pytest -v -s --collect-only -m alpha
====================================================================================================================== test session starts =======================================================================================================================
platform linux2 -- Python 2.7.9, pytest-3.0.5, py-1.4.32, pluggy-0.4.0 -- /home/thayfield/virtualEnvs/clean/bin/python
cachedir: .cache
rootdir: /home/thayfield/projects/hm800/tmp/pytest_bug, inifile: 
collected 4 items 
<Module 'test_bug.py'>
  <Function 'test_bug[0]'>

======================================================================================================================= 3 tests deselected =======================================================================================================================
================================================================================================================== 3 deselected in 0.01 seconds ==================================================================================================================

Missing from the above is "<Function 'test_symbug[alpha]'>"

This reproduces in a clean virtual environment with python 2.7.9 and pytest 3.0.5 installed.

$uname -a
Linux copernicus 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux

Is this a known issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressedtype: feature-branchnew feature or API change, should be merged into features branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions