From commits-noreply at bitbucket.org Fri Mar 9 13:13:36 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Fri, 09 Mar 2012 12:13:36 -0000 Subject: [py-svn] commit/pytest: RonnyPfannschmidt: junitxml: use a exclusive match on the legal ranges of xml for binary escaping, fixes issue 126 Message-ID: <20120309121336.3842.11700@bitbucket05.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/changeset/cb796d949a0b/ changeset: cb796d949a0b user: RonnyPfannschmidt date: 2012-03-09 13:12:18 summary: junitxml: use a exclusive match on the legal ranges of xml for binary escaping, fixes issue 126 affected #: 3 files diff -r 7acac2f3fa415682a7f9354fc71cbbbf45d91954 -r cb796d949a0b557dafe3c9abb9758db7dd691a1e CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +Changese between 2.2.3 and ... +----------------------------------- + +- fix issue 126: correctly match all invalid xml characters for junitxml + binary escape + Changes between 2.2.2 and 2.2.3 ---------------------------------------- diff -r 7acac2f3fa415682a7f9354fc71cbbbf45d91954 -r cb796d949a0b557dafe3c9abb9758db7dd691a1e _pytest/junitxml.py --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -34,15 +34,21 @@ # this dynamically instead of hardcoding it. The spec range of valid # chars is: Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] # | [#x10000-#x10FFFF] -_illegal_unichrs = [(0x00, 0x08), (0x0B, 0x0C), (0x0E, 0x19), - (0xD800, 0xDFFF), (0xFDD0, 0xFFFF)] -_illegal_ranges = [unicode("%s-%s") % (unichr(low), unichr(high)) - for (low, high) in _illegal_unichrs +_legal_chars = (0x09, 0x0A, 0x0d) +_legal_ranges = ( + (0x20, 0xD7FF), + (0xE000, 0xFFFD), + (0x10000, 0x10FFFF), +) +_legal_xml_re = [unicode("%s-%s") % (unichr(low), unichr(high)) + for (low, high) in _legal_ranges if low < sys.maxunicode] -illegal_xml_re = re.compile(unicode('[%s]') % - unicode('').join(_illegal_ranges)) -del _illegal_unichrs -del _illegal_ranges +_legal_xml_re = [unichr(x) for x in _legal_chars] + _legal_xml_re +illegal_xml_re = re.compile(unicode('[^%s]') % + unicode('').join(_legal_xml_re)) +del _legal_chars +del _legal_ranges +del _legal_xml_re def bin_xml_escape(arg): def repl(matchobj): diff -r 7acac2f3fa415682a7f9354fc71cbbbf45d91954 -r cb796d949a0b557dafe3c9abb9758db7dd691a1e testing/test_junitxml.py --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -340,7 +340,7 @@ assert '#x0' in text -def test_invalid_xml_escape(testdir): +def test_invalid_xml_escape(): # Test some more invalid xml chars, the full range should be # tested really but let's just thest the edges of the ranges # intead. @@ -355,27 +355,23 @@ except NameError: unichr = chr u = py.builtin._totext - invalid = (0x1, 0xB, 0xC, 0xE, 0x19,) - # 0xD800, 0xDFFF, 0xFFFE, 0x0FFFF) #, 0x110000) + invalid = (0x00, 0x1, 0xB, 0xC, 0xE, 0x19, + 033, # issue #126 + 0xD800, 0xDFFF, 0xFFFE, 0x0FFFF) #, 0x110000) valid = (0x9, 0xA, 0x20,) # 0xD, 0xD7FF, 0xE000, 0xFFFD, 0x10000, 0x10FFFF) - all = invalid + valid - prints = [u(" sys.stdout.write('''0x%X-->%s<--''')") % (i, unichr(i)) - for i in all] - testdir.makepyfile(u("# -*- coding: UTF-8 -*-"), - u("import sys"), - u("def test_print_bytes():"), - u("\n").join(prints), - u(" assert False")) - xmlf = testdir.tmpdir.join('junit.xml') - result = testdir.runpytest('--junitxml=%s' % xmlf) - text = xmlf.read() + + from _pytest.junitxml import bin_xml_escape + + for i in invalid: + got = bin_xml_escape(unichr(i)) if i <= 0xFF: - assert '#x%02X' % i in text + expected = '#x%02X' % i else: - assert '#x%04X' % i in text + expected = '#x%04X' % i + assert got == expected for i in valid: - assert chr(i) in text + assert chr(i) == bin_xml_escape(unichr(i)) def test_logxml_path_expansion(): from _pytest.junitxml import LogXML 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. From py-svn at codespeak.net Mon Mar 12 15:29:17 2012 From: py-svn at codespeak.net (py-svn at codespeak.net) Date: Mon, 12 Mar 2012 15:29:17 +0100 (CET) Subject: [py-svn] py-svn@codespeak.net Breitling Discount ID20502 Message-ID: <20120312142917.125AD282B9E@codespeak.net> An HTML attachment was scrubbed... URL: From commits-noreply at bitbucket.org Tue Mar 13 12:13:16 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Tue, 13 Mar 2012 11:13:16 -0000 Subject: [py-svn] commit/py: 3 new changesets Message-ID: <20120313111316.16858.62560@bitbucket03.managed.contegix.com> 3 new commits in py: https://bitbucket.org/hpk42/py/changeset/6903d3d93c9c/ changeset: 6903d3d93c9c user: RonnyPfannschmidt date: 2012-03-13 09:37:00 summary: add missing unicode transform to the xml serialization affected #: 1 file diff -r b418f117d16a960b5c276f06b51b4fe2d4ff3e80 -r 6903d3d93c9c961c87291279010c16ae97a939d3 py/_xmlgen.py --- a/py/_xmlgen.py +++ b/py/_xmlgen.py @@ -52,7 +52,7 @@ def unicode(self, indent=2): l = [] SimpleUnicodeVisitor(l.append, indent).visit(self) - return "".join(l) + return u("").join(l) def __repr__(self): name = self.__class__.__name__ https://bitbucket.org/hpk42/py/changeset/1c3cea86db99/ changeset: 1c3cea86db99 user: RonnyPfannschmidt date: 2012-03-13 09:37:00 summary: special case for tags in xmlgen to work for the object tag, fixes #13 affected #: 3 files diff -r 6903d3d93c9c961c87291279010c16ae97a939d3 -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Changes between 1.4.7 and 1.4.8 +================================================== + +- fix issue 13 - correct handling of the tag name object in xmlgen + Changes between 1.4.6 and 1.4.7 ================================================== diff -r 6903d3d93c9c961c87291279010c16ae97a939d3 -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef py/_xmlgen.py --- a/py/_xmlgen.py +++ b/py/_xmlgen.py @@ -122,11 +122,13 @@ if visitmethod is not None: break else: - visitmethod = self.object + visitmethod = self.__object self.cache[cls] = visitmethod visitmethod(node) - def object(self, obj): + # the default fallback handler is marked private + # to avoid clashes with the tag name object + def __object(self, obj): #self.write(obj) self.write(escape(unicode(obj))) diff -r 6903d3d93c9c961c87291279010c16ae97a939d3 -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef testing/root/test_xmlgen.py --- a/testing/root/test_xmlgen.py +++ b/testing/root/test_xmlgen.py @@ -134,3 +134,6 @@ assert (h.unicode(indent=2) == '
foobar
') +def test_object_tags(): + o = html.object(html.object()) + assert o.unicode(indent=0) == '' https://bitbucket.org/hpk42/py/changeset/2c042feb5b3b/ changeset: 2c042feb5b3b user: RonnyPfannschmidt date: 2012-03-13 09:37:00 summary: xmlgen: support using raw for attribute values, fixes #14 affected #: 3 files diff -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef -r 2c042feb5b3b1acebc7ceb565cac0a3b72d2a732 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ ================================================== - fix issue 13 - correct handling of the tag name object in xmlgen +- fix issue 14 - support raw attribute values in xmlgen Changes between 1.4.6 and 1.4.7 ================================================== diff -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef -r 2c042feb5b3b1acebc7ceb565cac0a3b72d2a732 py/_xmlgen.py --- a/py/_xmlgen.py +++ b/py/_xmlgen.py @@ -184,7 +184,11 @@ value = getattr(attrs, name) if name.endswith('_'): name = name[:-1] - return ' %s="%s"' % (name, escape(unicode(value))) + if isinstance(value, raw): + insert = value.uniobj + else: + insert = escape(unicode(value)) + return ' %s="%s"' % (name, insert) def getstyle(self, tag): """ return attribute list suitable for styling. """ diff -r 1c3cea86db99cf048e3a4e708acd769ee5efd2ef -r 2c042feb5b3b1acebc7ceb565cac0a3b72d2a732 testing/root/test_xmlgen.py --- a/testing/root/test_xmlgen.py +++ b/testing/root/test_xmlgen.py @@ -1,6 +1,6 @@ import py -from py._xmlgen import unicode, html +from py._xmlgen import unicode, html, raw class ns(py.xml.Namespace): pass @@ -47,6 +47,10 @@ assert x.attr.hello == 'world' assert unicode(x) == '' +def test_tag_with_raw_attr(): + x = html.object(data=raw('&')) + assert unicode(x) == '' + def test_tag_nested(): x = ns.hello(ns.world()) unicode(x) # triggers parentifying Repository URL: https://bitbucket.org/hpk42/py/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. From commits-noreply at bitbucket.org Thu Mar 15 15:15:30 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Thu, 15 Mar 2012 14:15:30 -0000 Subject: [py-svn] commit/pytest: RonnyPfannschmidt: document integration with setuptools/distribute test command and tests_require Message-ID: <20120315141530.19582.19531@bitbucket02.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/changeset/8857eb90c8ea/ changeset: 8857eb90c8ea user: RonnyPfannschmidt date: 2012-03-15 15:15:21 summary: document integration with setuptools/distribute test command and tests_require affected #: 2 files diff -r cb796d949a0b557dafe3c9abb9758db7dd691a1e -r 8857eb90c8ead72f0ade7686d57bc3e3be596f30 CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ - fix issue 126: correctly match all invalid xml characters for junitxml binary escape +- document integration with the extended distribute/setuptools test commands + Changes between 2.2.2 and 2.2.3 ---------------------------------------- diff -r cb796d949a0b557dafe3c9abb9758db7dd691a1e -r 8857eb90c8ead72f0ade7686d57bc3e3be596f30 doc/goodpractises.txt --- a/doc/goodpractises.txt +++ b/doc/goodpractises.txt @@ -94,6 +94,40 @@ .. _`test discovery`: .. _`Python test discovery`: + +Integration with setuptools/distribute test commands +---------------------------------------------------- + +Distribute/Setuptools support test requirements, +which means its really easy to extend its test command +to support running a pytest from test requirements:: + + from setuptools.command.test import test as TestCommand + + class PyTest(TestCommand): + def finalize_options(self): + TestCommand.finalize_options(self) + self.test_args = [] + self.test_suite = True + def run_tests(self): + #import here, cause outside the eggs aren't loaded + import pytest + pytest.main(self.test_args) + + setup( + ..., + tests_require=['pytest'], + cmdclass = {'test': pytest}, + ) + +Now if you run:: + + python setup.py test + +this will download py.test if needed and then run py.test +as you would expect it to. + + Conventions for Python test discovery ------------------------------------------------- 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. From commits-noreply at bitbucket.org Thu Mar 15 15:22:21 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Thu, 15 Mar 2012 14:22:21 -0000 Subject: [py-svn] commit/pytest: RonnyPfannschmidt: add acomment so highlighting won\'t fail Message-ID: <20120315142221.24444.72603@bitbucket03.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/changeset/6c209f9cfe00/ changeset: 6c209f9cfe00 user: RonnyPfannschmidt date: 2012-03-15 15:22:13 summary: add acomment so highlighting won\'t fail affected #: 1 file diff -r 8857eb90c8ead72f0ade7686d57bc3e3be596f30 -r 6c209f9cfe007a7730a39dd3f3e73babba42e553 doc/goodpractises.txt --- a/doc/goodpractises.txt +++ b/doc/goodpractises.txt @@ -115,7 +115,7 @@ pytest.main(self.test_args) setup( - ..., + #..., tests_require=['pytest'], cmdclass = {'test': pytest}, ) 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. From commits-noreply at bitbucket.org Mon Mar 19 16:53:15 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Mon, 19 Mar 2012 15:53:15 -0000 Subject: [py-svn] commit/pytest: 2 new changesets Message-ID: <20120319155315.8315.4689@bitbucket15.managed.contegix.com> 2 new commits in pytest: https://bitbucket.org/hpk42/pytest/changeset/b62a43a350c0/ changeset: b62a43a350c0 user: hpk42 date: 2012-03-19 14:56:35 summary: walk through issues affected #: 1 file diff -r 6c209f9cfe007a7730a39dd3f3e73babba42e553 -r b62a43a350c0dc3ce1b3dbe33bd0f68f0933cd8f ISSUES.txt --- a/ISSUES.txt +++ b/ISSUES.txt @@ -1,6 +1,14 @@ -refine parametrize API in 2.2 series + +improve / add to dependency/test resource injection ------------------------------------------------------------- -tags: critical feature 2.2 +tags: wish feature docs + +write up better examples showing the connection between +the two. + +refine parametrize API +------------------------------------------------------------- +tags: critical feature extend metafunc.parametrize to better support indirection by specifying a setupfunc(request, val) which will _substitute_ @@ -16,8 +24,28 @@ def test_heavy_functional_test(db): ... -There would be no need to write funcarg factories for this example, only -to explain the attributes and functionality of "request". +There would be no need to write or explain funcarg factories here. + +The examples and improvements should also show how to put the parametrize +decorator to a class, to a module or even to a directory. For the directory +part a conftest.py content like this:: + + pytestmark = [ + @pytest.mark.parametrize("db", ...), + ] + +probably makes sense in order to keep the declarative nature. This mirrors +the marker-mechanism with respect to a test module but puts it to a directory +scale. + +When doing larger scoped parametrization it probably becomes neccessary +to allow parametrization to not match - currently any parametrized argument +that is not present in a function will cause a ValueError. With + + @pytest.mark.parametrize("db", ..., mustmatch=False) + +we can tell pytest to not raise an error but simply ignore the parametrization +if the signature of a decorated function does not match. checks / deprecations for next release --------------------------------------------------------------- @@ -48,7 +76,7 @@ do early-teardown of test modules ----------------------------------------- -tags: feature 2.3 +tags: feature currently teardowns are called when the next tests is setup except for the function/method level where interally @@ -60,7 +88,7 @@ consider and document __init__ file usage in test directories --------------------------------------------------------------- -tags: bug 2.3 core +tags: bug core Currently, a test module is imported with its fully qualified package path, determined by checking __init__ files upwards. @@ -75,7 +103,7 @@ relax requirement to have tests/testing contain an __init__ ---------------------------------------------------------------- -tags: feature 2.3 +tags: feature bb: http://bitbucket.org/hpk42/py-trunk/issue/64 A local test run of a "tests" directory may work @@ -86,7 +114,7 @@ customize test function collection ------------------------------------------------------- -tags: feature 2.3 +tags: feature - introduce py.test.mark.nocollect for not considering a function for test collection at all. maybe also introduce a py.test.mark.test to @@ -95,7 +123,7 @@ introduce pytest.mark.importorskip ------------------------------------------------------- -tags: feature 2.3 +tags: feature in addition to the imperative pytest.importorskip also introduce a pytest.mark.importorskip so that the test count is more correct. @@ -103,7 +131,7 @@ introduce py.test.mark.platform ------------------------------------------------------- -tags: feature 2.3 +tags: feature Introduce nice-to-spell platform-skipping, examples: @@ -120,7 +148,7 @@ pytest.mark.xfail signature change ------------------------------------------------------- -tags: feature 2.3 +tags: feature change to pytest.mark.xfail(reason, (optional)condition) to better implement the word meaning. It also signals @@ -128,36 +156,27 @@ reason that can be formualated. Compatibility? how to introduce a new name/keep compat? -introduce py.test.mark registration ------------------------------------------ -tags: feature 2.3 - -introduce a hook that allows to register a named mark decorator -with documentation and add "py.test --marks" to get -a list of available marks. Deprecate "dynamic" mark -definitions. - allow to non-intrusively apply skipfs/xfail/marks --------------------------------------------------- -tags: feature 2.3 +tags: feature use case: mark a module or directory structures to be skipped on certain platforms (i.e. no import attempt will be made). consider introducing a hook/mechanism that allows to apply marks -from conftests or plugins. +from conftests or plugins. (See extended parametrization) explicit referencing of conftest.py files ----------------------------------------- -tags: feature 2.3 +tags: feature allow to name conftest.py files (in sub directories) that should be imported early, as to include command line options. improve central py.test ini file ---------------------------------- -tags: feature 2.3 +tags: feature introduce more declarative configuration options: - (to-be-collected test directories) @@ -168,7 +187,7 @@ new documentation ---------------------------------- -tags: feature 2.3 +tags: feature - logo py.test - examples for unittest or functional testing @@ -177,23 +196,15 @@ have imported module mismatch honour relative paths -------------------------------------------------------- -tags: bug 2.3 +tags: bug With 1.1.1 py.test fails at least on windows if an import is relative and compared against an absolute conftest.py path. Normalize. -call termination with small timeout -------------------------------------------------- -tags: feature 2.3 -test: testing/pytest/dist/test_dsession.py - test_terminate_on_hanging_node - -Call gateway group termination with a small timeout if available. -Should make dist-testing less likely to leave lost processes. - consider globals: py.test.ensuretemp and config -------------------------------------------------------------- -tags: experimental-wish 2.3 +tags: experimental-wish consider deprecating py.test.ensuretemp and py.test.config to further reduce py.test globality. Also consider @@ -202,7 +213,7 @@ consider allowing funcargs for setup methods -------------------------------------------------------------- -tags: experimental-wish 2.3 +tags: experimental-wish Users have expressed the wish to have funcargs available to setup functions. Experiment with allowing funcargs there - it might @@ -225,7 +236,7 @@ consider pytest_addsyspath hook ----------------------------------------- -tags: 2.3 +tags: py.test could call a new pytest_addsyspath() in order to systematically allow manipulation of sys.path and to inhibit it via --no-addsyspath @@ -237,7 +248,7 @@ show plugin information in test header ---------------------------------------------------------------- -tags: feature 2.3 +tags: feature Now that external plugins are becoming more numerous it would be useful to have external plugins along with @@ -245,7 +256,7 @@ deprecate global py.test.config usage ---------------------------------------------------------------- -tags: feature 2.3 +tags: feature py.test.ensuretemp and py.test.config are probably the last objects containing global state. Often using them is not @@ -255,7 +266,7 @@ remove deprecated bits in collect.py ------------------------------------------------------------------- -tags: feature 2.3 +tags: feature In an effort to further simplify code, review and remove deprecated bits in collect.py. Probably good: @@ -264,7 +275,7 @@ implement fslayout decorator --------------------------------- -tags: feature 2.3 +tags: feature Improve the way how tests can work with pre-made examples, keeping the layout close to the test function: @@ -278,9 +289,7 @@ pass """) def test_run(pytester, fslayout): - p = fslayout.find("test_*.py") + p = fslayout.findone("test_*.py") result = pytester.runpytest(p) assert result.ret == 0 assert result.passed == 1 - - https://bitbucket.org/hpk42/pytest/changeset/2293cd9ddd82/ changeset: 2293cd9ddd82 user: hpk42 date: 2012-03-19 16:53:08 summary: bump version number to dev version affected #: 2 files diff -r b62a43a350c0dc3ce1b3dbe33bd0f68f0933cd8f -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.3' +__version__ = '2.2.4.dev1' diff -r b62a43a350c0dc3ce1b3dbe33bd0f68f0933cd8f -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 setup.py --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.3', + version='2.2.4.dev1', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], 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. From commits-noreply at bitbucket.org Tue Mar 20 01:05:04 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Tue, 20 Mar 2012 00:05:04 -0000 Subject: [py-svn] commit/pytest: gutworth: remove unused import Message-ID: <20120320000504.11353.29373@bitbucket05.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/changeset/b05a58c4553f/ changeset: b05a58c4553f user: gutworth date: 2012-03-20 01:04:55 summary: remove unused import affected #: 1 file diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r b05a58c4553f18143cfe3278b77a04054d56720e _pytest/assertion/rewrite.py --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -1,7 +1,6 @@ """Rewrite assertion AST to produce nice error messages""" import ast -import collections import errno import itertools import imp 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. From commits-noreply at bitbucket.org Thu Mar 22 08:27:09 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Thu, 22 Mar 2012 07:27:09 -0000 Subject: [py-svn] commit/pytest: RonnyPfannschmidt: word change in the docs fixes #130 Message-ID: <20120322072709.31008.43482@bitbucket03.managed.contegix.com> 1 new commit in pytest: https://bitbucket.org/hpk42/pytest/changeset/4522e6bb851e/ changeset: 4522e6bb851e user: RonnyPfannschmidt date: 2012-03-22 08:26:37 summary: word change in the docs fixes #130 affected #: 1 file diff -r b05a58c4553f18143cfe3278b77a04054d56720e -r 4522e6bb851e4d8d040c93d57a272a5eaf755748 doc/usage.txt --- a/doc/usage.txt +++ b/doc/usage.txt @@ -70,7 +70,7 @@ .. _PDB: http://docs.python.org/library/pdb.html Python comes with a builtin Python debugger called PDB_. ``py.test`` -allows to drop into the PDB prompt via a command line option:: +allows one to drop into the PDB prompt via a command line option:: py.test --pdb 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. From commits-noreply at bitbucket.org Sat Mar 31 19:13:02 2012 From: commits-noreply at bitbucket.org (Bitbucket) Date: Sat, 31 Mar 2012 17:13:02 -0000 Subject: [py-svn] commit/pytest: 3 new changesets Message-ID: <20120331171302.14382.10704@bitbucket01.managed.contegix.com> 3 new commits in pytest: https://bitbucket.org/hpk42/pytest/changeset/c1f7182fa138/ changeset: c1f7182fa138 user: hpk42 date: 2012-03-20 06:53:52 summary: try to better handle @unittest.expectedFailure decorator affected #: 6 files diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d CHANGELOG --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ - fix issue 126: correctly match all invalid xml characters for junitxml binary escape +- fix issue with unittest: now @unittest.expectedFailure markers should + be processed correctly (you can also use @pytest.mark markers) - document integration with the extended distribute/setuptools test commands diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d _pytest/__init__.py --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.4.dev1' +__version__ = '2.2.4.dev2' diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d _pytest/skipping.py --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -132,6 +132,14 @@ def pytest_runtest_makereport(__multicall__, item, call): if not isinstance(item, pytest.Function): return + # unitttest special case, see setting of _unexpectedsuccess + if hasattr(item, '_unexpectedsuccess'): + rep = __multicall__.execute() + if rep.when == "call": + # we need to translate into how py.test encodes xpass + rep.keywords['xfail'] = "reason: " + item._unexpectedsuccess + rep.outcome = "failed" + return rep if not (call.excinfo and call.excinfo.errisinstance(py.test.xfail.Exception)): evalxfail = getattr(item, '_evalxfail', None) diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d _pytest/unittest.py --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -91,22 +91,28 @@ self._addexcinfo(rawexcinfo) def addFailure(self, testcase, rawexcinfo): self._addexcinfo(rawexcinfo) + def addSkip(self, testcase, reason): try: pytest.skip(reason) except pytest.skip.Exception: self._addexcinfo(sys.exc_info()) - def addExpectedFailure(self, testcase, rawexcinfo, reason): + + def addExpectedFailure(self, testcase, rawexcinfo, reason=""): try: pytest.xfail(str(reason)) except pytest.xfail.Exception: self._addexcinfo(sys.exc_info()) - def addUnexpectedSuccess(self, testcase, reason): - pass + + def addUnexpectedSuccess(self, testcase, reason=""): + self._unexpectedsuccess = reason + def addSuccess(self, testcase): pass + def stopTest(self, testcase): pass + def runtest(self): self._testcase(result=self) diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d setup.py --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.2.4.dev1', + version='2.2.4.dev2', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff -r 2293cd9ddd8209cbc962af1d1294ff4564ef29b5 -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d testing/test_unittest.py --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -459,3 +459,24 @@ result = testdir.runpytest() assert "TypeError" in result.stdout.str() assert result.ret == 1 + + at pytest.mark.skipif("sys.version_info < (2,7)") +def test_unittest_unexpected_failure(testdir): + testdir.makepyfile(""" + import unittest + class MyTestCase(unittest.TestCase): + @unittest.expectedFailure + def test_func1(self): + assert 0 + @unittest.expectedFailure + def test_func2(self): + assert 1 + """) + result = testdir.runpytest("-rxX") + result.stdout.fnmatch_lines([ + "*XFAIL*MyTestCase*test_func1*", + "*XPASS*MyTestCase*test_func2*", + "*1 xfailed*1 xpass*", + ]) + + https://bitbucket.org/hpk42/pytest/changeset/cfa638ab8c1c/ changeset: cfa638ab8c1c user: hpk42 date: 2012-03-31 19:12:11 summary: merge affected #: 2 files diff -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d -r cfa638ab8c1ca6386c970070551c9a81cfda4eb1 _pytest/assertion/rewrite.py --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -1,7 +1,6 @@ """Rewrite assertion AST to produce nice error messages""" import ast -import collections import errno import itertools import imp diff -r c1f7182fa1382825d9cd7a0b4102caecf2e3a91d -r cfa638ab8c1ca6386c970070551c9a81cfda4eb1 doc/usage.txt --- a/doc/usage.txt +++ b/doc/usage.txt @@ -70,7 +70,7 @@ .. _PDB: http://docs.python.org/library/pdb.html Python comes with a builtin Python debugger called PDB_. ``py.test`` -allows to drop into the PDB prompt via a command line option:: +allows one to drop into the PDB prompt via a command line option:: py.test --pdb https://bitbucket.org/hpk42/pytest/changeset/4d4ce0192c29/ changeset: 4d4ce0192c29 user: hpk42 date: 2012-03-31 19:01:03 summary: write down some thoughts on parametrization - still not completely clear what the next stage should look like ... affected #: 1 file diff -r cfa638ab8c1ca6386c970070551c9a81cfda4eb1 -r 4d4ce0192c296472a9cd0ad513d81950e4cc9502 ISSUES.txt --- a/ISSUES.txt +++ b/ISSUES.txt @@ -10,28 +10,27 @@ ------------------------------------------------------------- tags: critical feature -extend metafunc.parametrize to better support indirection -by specifying a setupfunc(request, val) which will _substitute_ -the funcarg factory. Here is an example: +extend metafunc.parametrize to directly support indirection, example: - def setupdb(request, val): + def setupdb(request, config): # setup "resource" based on test request and the values passed # in to parametrize. setupfunc is called for each such value. # you may use request.addfinalizer() or request.cached_setup ... - return db + return dynamic_setup_database(val) @pytest.mark.parametrize("db", ["pg", "mysql"], setupfunc=setupdb) def test_heavy_functional_test(db): ... -There would be no need to write or explain funcarg factories here. +There would be no need to write or explain funcarg factories and +their special __ syntax. The examples and improvements should also show how to put the parametrize decorator to a class, to a module or even to a directory. For the directory part a conftest.py content like this:: pytestmark = [ - @pytest.mark.parametrize("db", ...), + @pytest.mark.parametrize_setup("db", ...), ] probably makes sense in order to keep the declarative nature. This mirrors @@ -39,13 +38,87 @@ scale. When doing larger scoped parametrization it probably becomes neccessary -to allow parametrization to not match - currently any parametrized argument -that is not present in a function will cause a ValueError. With +to allow parametrization to be ignored if the according parameter is not +used (currently any parametrized argument that is not present in a function will cause a ValueError). Example: @pytest.mark.parametrize("db", ..., mustmatch=False) -we can tell pytest to not raise an error but simply ignore the parametrization -if the signature of a decorated function does not match. +means to not raise an error but simply ignore the parametrization +if the signature of a decorated function does not match. XXX is it +not sufficient to always allow non-matches? + + +unify item/request classes, generalize items +--------------------------------------------------------------- +tags: 2.4 wish + +in lieu of extended parametrization and the new way to specify resource +factories in terms of the parametrize decorator, consider unification +of the item and request class. This also is connected with allowing +funcargs in setup functions. Example of new item API: + + item.getresource("db") # alias for request.getfuncargvalue + item.addfinalizer(...) + item.cached_setup(...) + item.applymarker(...) + +test classes/modules could then use this api via:: + + def pytest_runtest_setup(item): + use item API ... + +introduction of this new method needs to be _fully_ backward compatible - +and the documentation needs to change along to mention this new way of +doing things. + +impl note: probably Request._fillfuncargs would be called from the +python plugins own pytest_runtest_setup(item) and would call +item.getresource(X) for all X in the funcargs of a function. + +XXX is it possible to even put the above item API to Nodes, i.e. also +to Directorty/module/file/class collectors? Problem is that current +funcarg factories presume they are called with a per-function (even +per-funcarg-per-function) scope. Could there be small tweaks to the new +API that lift this restriction? + +consider:: + + def setup_class(cls, tmpdir): + # would get a per-class tmpdir because tmpdir parametrization + # would know that it is called with a class scope + # + # + # +this looks very difficult because those setup functions are also used +by nose etc. Rather consider introduction of a new setup hook: + + def setup_test(self, item): + self.db = item.cached_setup(..., scope='class') + self.tmpdir = item.getresource("tmpdir") + +this should be compatible to unittest/nose and provide much of what +"testresources" provide. XXX This would not allow full parametrization +such that test function could be run multiple times with different +values. See "parametrized attributes" issue. + +allow parametrized attributes on classes +-------------------------------------------------- + +tags: wish 2.4 + +example: + + @pytest.mark.parametrize_attr("db", setupfunc, [1,2,3], scope="class") + @pytest.mark.parametrize_attr("tmp", setupfunc, scope="...") + class TestMe: + def test_hello(self): + access self.db ... + +this would run the test_hello() function three times with three +different values for self.db. This could also work with unittest/nose +style tests, i.e. it leverages existing test suites without needing +to rewrite them. Together with the previously mentioned setup_test() +maybe the setupfunc could be ommitted? checks / deprecations for next release --------------------------------------------------------------- @@ -74,18 +147,6 @@ record which implementations of a hook succeeded and only call their teardown. -do early-teardown of test modules ------------------------------------------ -tags: feature - -currently teardowns are called when the next tests is setup -except for the function/method level where interally -"teardown_exact" tears down immediately. Generalize -this to perform the "neccessary" teardown compared to -the "next" test item during teardown - this should -get rid of some irritations because otherwise e.g. -prints of teardown-code appear in the setup of the next test. - consider and document __init__ file usage in test directories --------------------------------------------------------------- tags: bug core @@ -167,6 +228,7 @@ consider introducing a hook/mechanism that allows to apply marks from conftests or plugins. (See extended parametrization) + explicit referencing of conftest.py files ----------------------------------------- tags: feature 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.