From 7a918a161737b56ee6f692abcdb79aaa0646caef Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 30 Jul 2015 23:21:19 -0300 Subject: [PATCH 1/4] Fix regendoc section in fixture.txt Noticed thanks to #903 --- doc/en/fixture.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/en/fixture.txt b/doc/en/fixture.txt index 7ed8399de..31dfdd358 100644 --- a/doc/en/fixture.txt +++ b/doc/en/fixture.txt @@ -443,6 +443,7 @@ make a string based on the argument name. It is possible to customise the string used in a test ID for a certain fixture value by using the ``ids`` keyword argument:: + # content of test_ids.py import pytest @pytest.fixture(params=[0, 1], ids=["spam", "ham"]) @@ -472,7 +473,7 @@ return ``None`` then pytest's auto-generated ID will be used. Running the above tests results in the following test IDs being used:: - $ py.test --collect-only + $ py.test --collect-only test_ids.py =========================== test session starts ============================ platform linux -- Python 3.4.1 -- py-1.4.27 -- pytest-2.7.1 rootdir: /tmp/doc-exec-98, inifile: From 4d8e3cbcb0afc94324f35b78a14ed87922914015 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 30 Jul 2015 23:46:25 -0300 Subject: [PATCH 2/4] Use smtp.gmail.com server for examples and fixes examples for python 3 Examples in py3 where showing the wrong message: TypeError: Type str doesn't support the buffer API --- doc/en/fixture.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/en/fixture.txt b/doc/en/fixture.txt index 31dfdd358..72cd9f2fd 100644 --- a/doc/en/fixture.txt +++ b/doc/en/fixture.txt @@ -62,7 +62,7 @@ using it:: @pytest.fixture def smtp(): import smtplib - return smtplib.SMTP("merlinux.eu") + return smtplib.SMTP("smtp.gmail.com") def test_ehlo(smtp): response, msg = smtp.ehlo() @@ -169,7 +169,7 @@ access the fixture function:: @pytest.fixture(scope="module") def smtp(): - return smtplib.SMTP("merlinux.eu") + return smtplib.SMTP("smtp.gmail.com") The name of the fixture again is ``smtp`` and you can access its result by listing the name ``smtp`` as an input parameter in any test or fixture @@ -178,14 +178,14 @@ function (in or below the directory where ``conftest.py`` is located):: # content of test_module.py def test_ehlo(smtp): - response = smtp.ehlo() - assert response[0] == 250 - assert "merlinux" in response[1] + response, msg = smtp.ehlo() + assert response == 250 + assert "smtp.gmail.com" in str(msg, 'ascii') assert 0 # for demo purposes def test_noop(smtp): - response = smtp.noop() - assert response[0] == 250 + response, msg = smtp.noop() + assert response == 250 assert 0 # for demo purposes We deliberately insert failing ``assert 0`` statements in order to @@ -255,7 +255,7 @@ or multiple times:: @pytest.fixture(scope="module") def smtp(request): - smtp = smtplib.SMTP("merlinux.eu") + smtp = smtplib.SMTP("smtp.gmail.com") def fin(): print ("teardown smtp") smtp.close() @@ -296,7 +296,7 @@ read an optional server URL from the test module which uses our fixture:: @pytest.fixture(scope="module") def smtp(request): - server = getattr(request.module, "smtpserver", "merlinux.eu") + server = getattr(request.module, "smtpserver", "smtp.gmail.com") smtp = smtplib.SMTP(server) def fin(): @@ -359,7 +359,7 @@ through the special :py:class:`request ` object:: import smtplib @pytest.fixture(scope="module", - params=["merlinux.eu", "mail.python.org"]) + params=["smtp.gmail.com", "mail.python.org"]) def smtp(request): smtp = smtplib.SMTP(request.param) def fin(): @@ -431,7 +431,7 @@ connection the second test fails in ``test_ehlo`` because a different server string is expected than what arrived. pytest will build a string that is the test ID for each fixture value -in a parametrized fixture, e.g. ``test_ehlo[merlinux.eu]`` and +in a parametrized fixture, e.g. ``test_ehlo[smtp.gmail.com]`` and ``test_ehlo[mail.python.org]`` in the above examples. These IDs can be used with ``-k`` to select specific cases to run, and they will also identify the specific case when one is failing. Running pytest From 16720b96b4e3eeeed232afbdf87b6bed78fa7806 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 15 Sep 2015 12:17:52 +0200 Subject: [PATCH 3/4] fix a few issues with pytest-2.7 branch and bump version number - importorskip: skip a test if we have a minversion but cannot parse version numbers due to pkg_resources not present - make runner tests work with latest xdist --- _pytest/__init__.py | 2 +- _pytest/runner.py | 16 +++++++++++----- testing/test_runner.py | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index a521e0f8a..3f6eb33bd 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.7.2' +__version__ = '2.7.3' diff --git a/_pytest/runner.py b/_pytest/runner.py index ad106b4b4..5cee8509f 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -1,10 +1,9 @@ """ basic collect and runtest protocol implementations """ import bdb import sys +import re from time import time -from pkg_resources import parse_version - import py import pytest from py._code.code import TerminalRepr @@ -496,7 +495,14 @@ def importorskip(modname, minversion=None): if minversion is None: return mod verattr = getattr(mod, '__version__', None) - if verattr is None or parse_version(verattr) < parse_version(minversion): - skip("module %r has __version__ %r, required is: %r" %( - modname, verattr, minversion)) + if minversion is not None: + try: + from pkg_resources import parse_version as pv + except ImportError: + skip("we have a required version for %r but can not import " + "no pkg_resources to parse version strings." %(modname,)) + if verattr is None or pv(verattr) < pv(minversion): + skip("module %r has __version__ %r, required is: %r" %( + modname, verattr, minversion)) return mod + diff --git a/testing/test_runner.py b/testing/test_runner.py index 167ddc57b..729a02b38 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -293,7 +293,7 @@ class TestExecutionForked(BaseFunctionalTests): def getrunner(self): # XXX re-arrange this test to live in pytest-xdist - xplugin = pytest.importorskip("xdist.plugin") + xplugin = pytest.importorskip("xdist.boxed") return xplugin.forked_run_report def test_suicide(self, testdir): From 5af262daa399842c8b03d8a287f8ee32174b0cc3 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 15 Sep 2015 12:28:09 +0200 Subject: [PATCH 4/4] fix flakes problem, configure devpi upload to always upload wheels and sdist --- _pytest/runner.py | 1 - setup.cfg | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/_pytest/runner.py b/_pytest/runner.py index 5cee8509f..32be7dbed 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -1,7 +1,6 @@ """ basic collect and runtest protocol implementations """ import bdb import sys -import re from time import time import py diff --git a/setup.cfg b/setup.cfg index 770dd1fb2..e9aecb776 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,7 @@ upload-dir = doc/en/build/html [bdist_wheel] universal = 1 + +[devpi:upload] +formats=sdist.tgz,bdist_wheel +