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

Do not show internal traceback when validating "parametrize" values #1860

Closed
nicoddemus opened this issue Aug 24, 2016 · 1 comment
Closed
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@nicoddemus
Copy link
Member

Consider:

import pytest
@pytest.mark.parametrize("x, expected", [(10, 20), (40, 80)], ids=[1,2,3])
def test_ids_numbers(x,expected):
    assert x * 2 == expected

Running this on pytest-3.0.1 produces:

=================================== ERRORS ====================================
______________________ ERROR collecting tmp/test_bug.py _______________________
X:\pytest\_pytest\runner.py:163: in __init__
    self.result = func()
X:\pytest\_pytest\main.py:460: in _memocollect
    return self._memoizedcall('_collected', lambda: list(self.collect()))
X:\pytest\_pytest\main.py:331: in _memoizedcall
    res = function()
X:\pytest\_pytest\main.py:460: in <lambda>
    return self._memoizedcall('_collected', lambda: list(self.collect()))
X:\pytest\_pytest\python.py:405: in collect
    return super(Module, self).collect()
X:\pytest\_pytest\python.py:319: in collect
    res = self.makeitem(name, obj)
X:\pytest\_pytest\python.py:331: in makeitem
    collector=self, name=name, obj=obj)
X:\pytest\_pytest\vendored_packages\pluggy.py:724: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
X:\pytest\_pytest\vendored_packages\pluggy.py:338: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
X:\pytest\_pytest\vendored_packages\pluggy.py:333: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
X:\pytest\_pytest\vendored_packages\pluggy.py:595: in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
X:\pytest\_pytest\vendored_packages\pluggy.py:249: in _wrapped_call
    wrap_controller.send(call_outcome)
X:\pytest\_pytest\python.py:192: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
X:\pytest\_pytest\python.py:351: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
X:\pytest\_pytest\vendored_packages\pluggy.py:724: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
X:\pytest\_pytest\vendored_packages\pluggy.py:338: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
X:\pytest\_pytest\vendored_packages\pluggy.py:333: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
X:\pytest\_pytest\vendored_packages\pluggy.py:596: in execute
    res = hook_impl.function(*args)
X:\pytest\_pytest\python.py:105: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
X:\pytest\_pytest\python.py:838: in parametrize
    len(argvalues), len(ids)))
E   ValueError: 2 tests specified with 3 ids
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.33 seconds ===========================

The error message is correct, but we should prevent that ugly internal traceback to show to users.

@nicoddemus nicoddemus added the type: enhancement new feature or API change, should be merged into features branch label Aug 24, 2016
@Zac-HD
Copy link
Member

Zac-HD commented Oct 24, 2019

================================== test session starts ==================================
platform win32 -- Python 3.6.5, pytest-5.1.3, py-1.7.0, pluggy-0.12.0
collected 0 items / 1 errors

======================================== ERRORS =========================================
_________________________________ ERROR collecting t.py _________________________________
In test_ids_numbers: 2 parameter sets specified, with different number of ids: 3
!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!
=================================== 1 error in 0.14s ====================================

Not sure when it was fixed, but it's not a problem on Pytest 5.1 😄

@Zac-HD Zac-HD closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants