3 new commits in pytest: https://bitbucket.org/hpk42/pytest/commits/434928c9c3da/ Changeset: 434928c9c3da User: hpk42 Date: 2013-07-16 11:30:21 Summary: add python testing training Affected #: 1 file
diff -r 5eca54d508b406369a0836f8f6422fd80a1836db -r 434928c9c3da6c841b8a80381da5bbd61ac5a694 doc/en/index.txt --- a/doc/en/index.txt +++ b/doc/en/index.txt @@ -1,6 +1,8 @@ .. _features: +.. note:: second training: `professional testing with Python <http://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_ , 25-27th November 2013, Leipzig. + pytest: helps you write better programs ============================================= https://bitbucket.org/hpk42/pytest/commits/f3c0eb5de5f5/ Changeset: f3c0eb5de5f5 User: hpk42 Date: 2013-07-16 15:32:05 Summary: merge better parametrize error messages, thanks Brianna Laugher Affected #: 3 files diff -r 434928c9c3da6c841b8a80381da5bbd61ac5a694 -r f3c0eb5de5f5b6782c7da20131602805d008d476 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,7 @@ - fix issue307 - use yaml.safe_load in example, thanks Mark Eichin. +- better parametrize error messages, thanks Brianna Laugher Changes between 2.3.4 and 2.3.5 ----------------------------------- diff -r 434928c9c3da6c841b8a80381da5bbd61ac5a694 -r f3c0eb5de5f5b6782c7da20131602805d008d476 _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -2,6 +2,7 @@ import py import inspect import sys +from types import NoneType import pytest from _pytest.main import getfslineno from _pytest.mark import MarkDecorator, MarkInfo @@ -709,6 +710,9 @@ raise ValueError("%r uses no fixture %r" %( self.function, arg)) valtype = indirect and "params" or "funcargs" + if ids and len(ids) != len(argvalues): + raise ValueError('%d tests specified with %d ids' %( + len(argvalues), len(ids))) if not ids: ids = idmaker(argnames, argvalues) newcalls = [] @@ -762,7 +766,7 @@ for valindex, valset in enumerate(argvalues): this_id = [] for nameindex, val in enumerate(valset): - if not isinstance(val, (float, int, str)): + if not isinstance(val, (float, int, str, bool, NoneType)): this_id.append(str(argnames[nameindex])+str(valindex)) else: this_id.append(str(val)) diff -r 434928c9c3da6c841b8a80381da5bbd61ac5a694 -r f3c0eb5de5f5b6782c7da20131602805d008d476 testing/python/metafunc.py --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -95,6 +95,17 @@ ids = [x.id for x in metafunc._calls] assert ids == ["basic-abc", "basic-def", "advanced-abc", "advanced-def"] + def test_parametrize_with_wrong_number_of_ids(self, testdir): + def func(x, y): pass + metafunc = self.Metafunc(func) + + with pytest.raises(ValueError): + metafunc.parametrize("x", [1,2], ids=['basic']) + + with pytest.raises(ValueError): + metafunc.parametrize(("x","y"), [("abc", "def"), + ("ghi", "jkl")], ids=["one"]) + def test_parametrize_with_userobjects(self): def func(x, y): pass metafunc = self.Metafunc(func) @@ -121,6 +132,25 @@ result = idmaker((py.builtin._totext("a"), "b"), [({}, '\xc3\xb4')]) assert result == ['a0-\xc3\xb4'] + def test_idmaker_native_strings(self): + from _pytest.python import idmaker + result = idmaker(("a", "b"), [(1.0, -1.1), + (2, -202), + ("three", "three hundred"), + (True, False), + (None, None), + (list("six"), [66, 66]), + ({7}, set("seven")), + (tuple("eight"), (8, -8, 8)) + ]) + assert result == ["1.0--1.1", + "2--202", + "three-three hundred", + "True-False", + "None-None", + "a5-b5", + "a6-b6", + "a7-b7"] def test_addcall_and_parametrize(self): def func(x, y): pass @@ -530,8 +560,6 @@ *test_function*1.3-b1* """) - - @pytest.mark.parametrize(("scope", "length"), [("module", 2), ("function", 4)]) def test_parametrize_scope_overrides(self, testdir, scope, length): https://bitbucket.org/hpk42/pytest/commits/6e5fd004c38d/ Changeset: 6e5fd004c38d User: hpk42 Date: 2013-07-16 15:43:20 Summary: some python2.5/3.3 fixes of Brianna's parametrize improvements Affected #: 4 files diff -r f3c0eb5de5f5b6782c7da20131602805d008d476 -r 6e5fd004c38df785e08fdad5d7eaf3095b8fbd0f _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.4.0.dev5' +__version__ = '2.4.0.dev6' diff -r f3c0eb5de5f5b6782c7da20131602805d008d476 -r 6e5fd004c38df785e08fdad5d7eaf3095b8fbd0f _pytest/python.py --- a/_pytest/python.py +++ b/_pytest/python.py @@ -2,7 +2,6 @@ import py import inspect import sys -from types import NoneType import pytest from _pytest.main import getfslineno from _pytest.mark import MarkDecorator, MarkInfo @@ -12,6 +11,8 @@ import _pytest cutdir = py.path.local(_pytest.__file__).dirpath() +NoneType = type(None) + callable = py.builtin.callable def getimfunc(func): diff -r f3c0eb5de5f5b6782c7da20131602805d008d476 -r 6e5fd004c38df785e08fdad5d7eaf3095b8fbd0f setup.py --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.4.0.dev5', + version='2.4.0.dev6', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r f3c0eb5de5f5b6782c7da20131602805d008d476 -r 6e5fd004c38df785e08fdad5d7eaf3095b8fbd0f testing/python/metafunc.py --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -99,12 +99,12 @@ def func(x, y): pass metafunc = self.Metafunc(func) - with pytest.raises(ValueError): - metafunc.parametrize("x", [1,2], ids=['basic']) + pytest.raises(ValueError, lambda: + metafunc.parametrize("x", [1,2], ids=['basic'])) - with pytest.raises(ValueError): + pytest.raises(ValueError, lambda: metafunc.parametrize(("x","y"), [("abc", "def"), - ("ghi", "jkl")], ids=["one"]) + ("ghi", "jkl")], ids=["one"])) def test_parametrize_with_userobjects(self): def func(x, y): pass @@ -140,7 +140,7 @@ (True, False), (None, None), (list("six"), [66, 66]), - ({7}, set("seven")), + (set([7]), set("seven")), (tuple("eight"), (8, -8, 8)) ]) assert result == ["1.0--1.1", Repository URL: https://bitbucket.org/hpk42/pytest/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit