merge, bump version

This commit is contained in:
holger krekel 2011-09-12 08:57:35 +02:00
commit 5c32421f2e
5 changed files with 35 additions and 15 deletions

View File

@ -1,6 +1,7 @@
Changes between 2.1.1 and [NEXT VERSION] Changes between 2.1.1 and [NEXT VERSION]
---------------------------------------- ----------------------------------------
- refine test discovery by package/module name (--pyargs), thanks Florian Mayer
- fix issue69 / assertion rewriting fixed on some boolean operations - fix issue69 / assertion rewriting fixed on some boolean operations
- fix issue68 / packages now work with assertion rewriting - fix issue68 / packages now work with assertion rewriting
- fix issue66: use different assertion rewriting caches when the -O option is passed - fix issue66: use different assertion rewriting caches when the -O option is passed

View File

@ -1,2 +1,2 @@
# #
__version__ = '2.1.1' __version__ = '2.1.2.dev1'

View File

@ -2,7 +2,7 @@
import py import py
import pytest, _pytest import pytest, _pytest
import os, sys import os, sys, imp
tracebackcutdir = py.path.local(_pytest.__file__).dirpath() tracebackcutdir = py.path.local(_pytest.__file__).dirpath()
# exitcodes for the command line # exitcodes for the command line
@ -469,16 +469,22 @@ class Session(FSCollector):
return True return True
def _tryconvertpyarg(self, x): def _tryconvertpyarg(self, x):
try: mod = None
mod = __import__(x, None, None, ['__doc__']) path = [os.path.abspath('.')] + sys.path
except (ValueError, ImportError): for name in x.split('.'):
return x try:
p = py.path.local(mod.__file__) fd, mod, type_ = imp.find_module(name, path)
if p.purebasename == "__init__": except ImportError:
p = p.dirpath() return x
else: else:
p = p.new(basename=p.purebasename+".py") if fd is not None:
return str(p) fd.close()
if type_[2] != imp.PKG_DIRECTORY:
path = [os.path.dirname(mod)]
else:
path = [mod]
return mod
def _parsearg(self, arg): def _parsearg(self, arg):
""" return (fspath, names) tuple after checking the file exists. """ """ return (fspath, names) tuple after checking the file exists. """

View File

@ -24,7 +24,7 @@ def main():
name='pytest', name='pytest',
description='py.test: simple powerful testing with Python', description='py.test: simple powerful testing with Python',
long_description = long_description, long_description = long_description,
version='2.1.1', version='2.1.2.dev1',
url='http://pytest.org', url='http://pytest.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -231,7 +231,7 @@ class TestGeneralUsage:
res = testdir.runpytest(p) res = testdir.runpytest(p)
assert res.ret == 0 assert res.ret == 0
res.stdout.fnmatch_lines(["*1 skipped*"]) res.stdout.fnmatch_lines(["*1 skipped*"])
def test_direct_addressing_selects(self, testdir): def test_direct_addressing_selects(self, testdir):
p = testdir.makepyfile(""" p = testdir.makepyfile("""
def pytest_generate_tests(metafunc): def pytest_generate_tests(metafunc):
@ -364,7 +364,7 @@ class TestInvocationVariants:
retcode = testdir.pytestmain(testdir.tmpdir) retcode = testdir.pytestmain(testdir.tmpdir)
assert not retcode assert not retcode
out, err = capsys.readouterr() out, err = capsys.readouterr()
def test_invoke_plugin_api(self, capsys): def test_invoke_plugin_api(self, capsys):
class MyPlugin: class MyPlugin:
def pytest_addoption(self, parser): def pytest_addoption(self, parser):
@ -374,6 +374,19 @@ class TestInvocationVariants:
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert "--myopt" in out assert "--myopt" in out
def test_pyargs_importerror(self, testdir, monkeypatch):
monkeypatch.delenv('PYTHONDONTWRITEBYTECODE', False)
path = testdir.mkpydir("tpkg")
path.join("test_hello.py").write('raise ImportError')
result = testdir.runpytest("--pyargs", "tpkg.test_hello")
assert result.ret != 0
# FIXME: It would be more natural to match NOT
# "ERROR*file*or*package*not*found*".
result.stdout.fnmatch_lines([
"*collected 0 items*"
])
def test_cmdline_python_package(self, testdir, monkeypatch): def test_cmdline_python_package(self, testdir, monkeypatch):
monkeypatch.delenv('PYTHONDONTWRITEBYTECODE', False) monkeypatch.delenv('PYTHONDONTWRITEBYTECODE', False)
path = testdir.mkpydir("tpkg") path = testdir.mkpydir("tpkg")