Skip to content

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

Closed

Description

@pytestbot

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.


Activity

  1. added
    type: enhancementnew feature or API change, should be merged into features branch
    on Jun 15, 2015
  2. pfctdayelise commented on Jul 25, 2015

    @pfctdayelise
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: parametrizerelated to @pytest.mark.parametrizetype: enhancementnew 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