From 27aa14c20f5f290f3c14ca8d72e1d692dff61a53 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 3 Jan 2010 13:27:06 +0100 Subject: [PATCH] fix python3 issues, add missing plugin docs --HG-- branch : trunk --- doc/test/plugin/genscript.txt | 29 +++++++++++++++++++++++++++ doc/test/plugin/logxml.txt | 29 +++++++++++++++++++++++++++ py/__init__.py | 1 - py/plugin/pytest_genscript.py | 7 ++++--- testing/path/conftest.py | 4 ++-- testing/plugin/test_pytest_restdoc.py | 4 ++++ 6 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 doc/test/plugin/genscript.txt create mode 100644 doc/test/plugin/logxml.txt diff --git a/doc/test/plugin/genscript.txt b/doc/test/plugin/genscript.txt new file mode 100644 index 000000000..0cc76d76f --- /dev/null +++ b/doc/test/plugin/genscript.txt @@ -0,0 +1,29 @@ + +pytest_genscript plugin +======================= + +generate standalone test script to be distributed along with an application. + +.. contents:: + :local: + + + +command line options +-------------------- + + +``--genscript=path`` + create standalone py.test script at given target path. + +Start improving this plugin in 30 seconds +========================================= + + +1. Download `pytest_genscript.py`_ plugin source code +2. put it somewhere as ``pytest_genscript.py`` into your import path +3. a subsequent ``py.test`` run will use your local version + +Checkout customize_, other plugins_ or `get in contact`_. + +.. include:: links.txt diff --git a/doc/test/plugin/logxml.txt b/doc/test/plugin/logxml.txt new file mode 100644 index 000000000..244e63bc7 --- /dev/null +++ b/doc/test/plugin/logxml.txt @@ -0,0 +1,29 @@ + +pytest_logxml plugin +==================== + +logging of test results in JUnit-XML format, for use with Hudson + +.. contents:: + :local: + +and build integration servers. Based on initial code from Ross Lawley. + +command line options +-------------------- + + +``--xml=path`` + create junit-xml style report file at the given path. + +Start improving this plugin in 30 seconds +========================================= + + +1. Download `pytest_logxml.py`_ plugin source code +2. put it somewhere as ``pytest_logxml.py`` into your import path +3. a subsequent ``py.test`` run will use your local version + +Checkout customize_, other plugins_ or `get in contact`_. + +.. include:: links.txt diff --git a/py/__init__.py b/py/__init__.py index f829d3425..4239a6825 100644 --- a/py/__init__.py +++ b/py/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ py.test and pylib: rapid testing and development utils diff --git a/py/plugin/pytest_genscript.py b/py/plugin/pytest_genscript.py index 87062657f..bf475f43d 100755 --- a/py/plugin/pytest_genscript.py +++ b/py/plugin/pytest_genscript.py @@ -44,16 +44,17 @@ def main(pybasedir, outfile, infile): name2src = {} for f in files: k = f.replace(os.sep, ".")[:-3] - name2src[k] = open(f, "rb").read() + name2src[k] = open(f, "r").read() data = pickle.dumps(name2src, 2) data = zlib.compress(data, 9) data = base64.encodestring(data) + data = data.decode("ascii") - exe = open(infile, "rb").read() + exe = open(infile, "r").read() exe = exe.replace("@SOURCES@", data) - open(outfile, "wb").write(exe) + open(outfile, "w").write(exe) os.chmod(outfile, 493) # 0755 sys.stdout.write("generated standalone py.test at %r, have fun!\n" % outfile) diff --git a/testing/path/conftest.py b/testing/path/conftest.py index 326d0852d..c47d7c4d5 100644 --- a/testing/path/conftest.py +++ b/testing/path/conftest.py @@ -17,7 +17,7 @@ def pytest_funcarg__repowc1(request): ) for x in ('test_remove', 'test_move', 'test_status_deleted'): if request.function.__name__.startswith(x): - print >>sys.stderr, ("saving repo", repo, "for", request.function) + #print >>sys.stderr, ("saving repo", repo, "for", request.function) _savedrepowc = save_repowc(repo, wc) request.addfinalizer(lambda: restore_repowc(_savedrepowc)) return repo, repourl, wc @@ -67,7 +67,7 @@ def save_repowc(repo, wc): def restore_repowc(obj): savedrepo, savedwc = obj - print >>sys.stderr, ("restoring", savedrepo) + #print >>sys.stderr, ("restoring", savedrepo) repo = savedrepo.new(basename=savedrepo.basename[:-2]) assert repo.check() wc = savedwc.new(basename=savedwc.basename[:-2]) diff --git a/testing/plugin/test_pytest_restdoc.py b/testing/plugin/test_pytest_restdoc.py index ce71f0d56..e26300a56 100644 --- a/testing/plugin/test_pytest_restdoc.py +++ b/testing/plugin/test_pytest_restdoc.py @@ -1,3 +1,4 @@ +import py from py.plugin.pytest_restdoc import deindent def test_deindent(): @@ -9,6 +10,9 @@ def test_deindent(): assert deindent(' foo\n bar\n') == ' foo\nbar\n' class TestDoctest: + def setup_class(cls): + py.test.importorskip("docutils") + def pytest_funcarg__testdir(self, request): testdir = request.getfuncargvalue("testdir") testdir.plugins.append("restdoc")