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

document and/or change display of parametrization values in IDs #249

Closed
pytestbot opened this issue Jan 15, 2013 · 1 comment
Closed

document and/or change display of parametrization values in IDs #249

pytestbot opened this issue Jan 15, 2013 · 1 comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Anonymous


There are some values of a parametrized argument that py.test seems unable to print to terminal during reports (or to file with --reportlog) - so far I have encountered it with UTF-8 content and the value None.

In the test report, it prints an internal identifier ('param6' for example).

Example script to reproduce:

#!python
# -*- coding: utf-8 -*-
import pytest

def pytest_generate_tests(metafunc):
    metavalues = ['test', u'Стоял он, дум великих полн', '<h1>HTML string</h1>', None, False,True,'']
    metafunc.parametrize('metastuff', metavalues)

def test_meta(metastuff):
    print '\n%s'%(metastuff)

Example output:

#!bash

platform linux2 -- Python 2.7.2 -- pytest-2.3.4 -- /home/james/qa_activepython27/bin/python
collected 7 items 

test_pytest_metanames.py:8: test_meta[test] 
test
PASSED
test_pytest_metanames.py:8: test_meta[metastuff1] 
Стоял он, дум великих полн
PASSED
test_pytest_metanames.py:8: test_meta[<h1>HTML string</h1>] 
<h1>HTML string</h1>
PASSED
test_pytest_metanames.py:8: test_meta[metastuff3] 
None
PASSED
test_pytest_metanames.py:8: test_meta[False] 
False
PASSED
test_pytest_metanames.py:8: test_meta[True] 
True
PASSED
test_pytest_metanames.py:8: test_meta[] 

PASSED

As you can see from the sample output, there's no issue with these values being printed to terminal in the general case.


@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
@pfctdayelise pfctdayelise added the topic: parametrize related to @pytest.mark.parametrize label Jul 25, 2015
@pfctdayelise
Copy link
Contributor

Support for custom IDs has been improved in the last year or so. And these all seem OK now.

@pytest.mark.parametrize('a', ['test', u'Стоял он, дум великих полн', '<h1>HTML string</h1>', None, False,True,''])
def test_params(a):
    print(a)

Output:

testing/test_foo.py::test_params[test] test
PASSED
testing/test_foo.py::test_params[Стоял он, дум великих полн] Стоял он, дум великих полн
PASSED
testing/test_foo.py::test_params[<h1>HTML string</h1>] <h1>HTML string</h1>
PASSED
testing/test_foo.py::test_params[None] None
PASSED
testing/test_foo.py::test_params[False] False
PASSED
testing/test_foo.py::test_params[True] True
PASSED
testing/test_foo.py::test_params[] 
PASSED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants