replace py.test module references with pytest
The only remaining 'py.test' references are: * those referring to the 'py.test' executable * those in code explicitly testing py.test/pytest module compatibility * those in old CHANGES documentation * those in documentation generated based on external data * those in seemingly unfinished & unmaintained Japanese documentation Minor stylistic changes and typo corrections made to documentation next to several applied py.test --> pytest content changes.
This commit is contained in:
@@ -28,7 +28,7 @@ def test_assert_with_explicit_message():
|
||||
assert e.msg == 'hello'
|
||||
|
||||
def test_assert_within_finally():
|
||||
excinfo = py.test.raises(ZeroDivisionError, """
|
||||
excinfo = pytest.raises(ZeroDivisionError, """
|
||||
try:
|
||||
1/0
|
||||
finally:
|
||||
@@ -79,7 +79,7 @@ def test_is():
|
||||
assert s.startswith("assert 1 is 2")
|
||||
|
||||
|
||||
@py.test.mark.skipif("sys.version_info < (2,6)")
|
||||
@pytest.mark.skipif("sys.version_info < (2,6)")
|
||||
def test_attrib():
|
||||
class Foo(object):
|
||||
b = 1
|
||||
@@ -91,7 +91,7 @@ def test_attrib():
|
||||
s = str(e)
|
||||
assert s.startswith("assert 1 == 2")
|
||||
|
||||
@py.test.mark.skipif("sys.version_info < (2,6)")
|
||||
@pytest.mark.skipif("sys.version_info < (2,6)")
|
||||
def test_attrib_inst():
|
||||
class Foo(object):
|
||||
b = 1
|
||||
@@ -168,7 +168,7 @@ def test_assert_with_brokenrepr_arg():
|
||||
def __repr__(self): 0 / 0
|
||||
e = AssertionError(BrokenRepr())
|
||||
if e.msg.find("broken __repr__") == -1:
|
||||
py.test.fail("broken __repr__ not handle correctly")
|
||||
pytest.fail("broken __repr__ not handle correctly")
|
||||
|
||||
def test_multiple_statements_per_line():
|
||||
try:
|
||||
@@ -244,7 +244,7 @@ class TestView:
|
||||
assert codelines == ["4 + 5", "getitem('', 'join')",
|
||||
"setattr('x', 'y', 3)", "12 - 1"]
|
||||
|
||||
@py.test.mark.skipif("sys.version_info < (2,6)")
|
||||
@pytest.mark.skipif("sys.version_info < (2,6)")
|
||||
def test_assert_customizable_reprcompare(monkeypatch):
|
||||
monkeypatch.setattr(util, '_reprcompare', lambda *args: 'hello')
|
||||
try:
|
||||
@@ -323,7 +323,7 @@ def test_assert_raises_in_nonzero_of_object_pytest_issue10():
|
||||
s = str(e)
|
||||
assert "<MY42 object> < 0" in s
|
||||
|
||||
@py.test.mark.skipif("sys.version_info >= (2,6)")
|
||||
@pytest.mark.skipif("sys.version_info >= (2,6)")
|
||||
def test_oldinterpret_importation():
|
||||
# we had a cyclic import there
|
||||
# requires pytest on sys.path
|
||||
|
||||
@@ -280,7 +280,7 @@ def test_options_on_small_file_do_not_blow_up(testdir):
|
||||
runfiletest(opts + [path])
|
||||
|
||||
def test_preparse_ordering_with_setuptools(testdir, monkeypatch):
|
||||
pkg_resources = py.test.importorskip("pkg_resources")
|
||||
pkg_resources = pytest.importorskip("pkg_resources")
|
||||
def my_iter(name):
|
||||
assert name == "pytest11"
|
||||
class EntryPoint:
|
||||
@@ -302,7 +302,7 @@ def test_preparse_ordering_with_setuptools(testdir, monkeypatch):
|
||||
assert plugin.x == 42
|
||||
|
||||
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch):
|
||||
pkg_resources = py.test.importorskip("pkg_resources")
|
||||
pkg_resources = pytest.importorskip("pkg_resources")
|
||||
def my_iter(name):
|
||||
assert name == "pytest11"
|
||||
class EntryPoint:
|
||||
|
||||
@@ -65,7 +65,7 @@ class TestBootstrapping:
|
||||
assert l2 == l3
|
||||
|
||||
def test_consider_setuptools_instantiation(self, monkeypatch):
|
||||
pkg_resources = py.test.importorskip("pkg_resources")
|
||||
pkg_resources = pytest.importorskip("pkg_resources")
|
||||
def my_iter(name):
|
||||
assert name == "pytest11"
|
||||
class EntryPoint:
|
||||
@@ -334,11 +334,11 @@ class TestPytestPluginInteractions:
|
||||
return {'hello': 'world'}
|
||||
""")
|
||||
p = testdir.makepyfile("""
|
||||
from py.test import hello
|
||||
import py
|
||||
from pytest import hello
|
||||
import pytest
|
||||
def test_hello():
|
||||
assert hello == "world"
|
||||
assert 'hello' in py.test.__all__
|
||||
assert 'hello' in pytest.__all__
|
||||
""")
|
||||
reprec = testdir.inline_run(p)
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
@@ -6,7 +6,7 @@ def test_version(testdir, pytestconfig):
|
||||
assert result.ret == 0
|
||||
#p = py.path.local(py.__file__).dirpath()
|
||||
result.stderr.fnmatch_lines([
|
||||
'*py.test*%s*imported from*' % (pytest.__version__, )
|
||||
'*pytest*%s*imported from*' % (pytest.__version__, )
|
||||
])
|
||||
if pytestconfig.pluginmanager._plugin_distinfo:
|
||||
result.stderr.fnmatch_lines([
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import py, pytest
|
||||
|
||||
def setup_module(mod):
|
||||
mod.nose = py.test.importorskip("nose")
|
||||
mod.nose = pytest.importorskip("nose")
|
||||
|
||||
def test_nose_setup(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
@@ -112,7 +112,7 @@ def test_nose_setup_func_failure_2(testdir):
|
||||
reprec.assertoutcome(passed=1)
|
||||
|
||||
def test_nose_setup_partial(testdir):
|
||||
py.test.importorskip("functools")
|
||||
pytest.importorskip("functools")
|
||||
p = testdir.makepyfile("""
|
||||
from functools import partial
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def test_parseconfig(testdir):
|
||||
config1 = testdir.parseconfig()
|
||||
config2 = testdir.parseconfig()
|
||||
assert config2 != config1
|
||||
assert config1 != py.test.config
|
||||
assert config1 != pytest.config
|
||||
|
||||
def test_testdir_runs_with_plugin(testdir):
|
||||
testdir.makepyfile("""
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_recwarn_functional(testdir):
|
||||
assert tuple(res) == (2, 0, 0), res
|
||||
|
||||
#
|
||||
# ============ test py.test.deprecated_call() ==============
|
||||
# ============ test pytest.deprecated_call() ==============
|
||||
#
|
||||
|
||||
def dep(i):
|
||||
@@ -53,14 +53,14 @@ def dep_explicit(i):
|
||||
|
||||
def test_deprecated_call_raises():
|
||||
excinfo = pytest.raises(AssertionError,
|
||||
"py.test.deprecated_call(dep, 3)")
|
||||
"pytest.deprecated_call(dep, 3)")
|
||||
assert str(excinfo).find("did not produce") != -1
|
||||
|
||||
def test_deprecated_call():
|
||||
py.test.deprecated_call(dep, 0)
|
||||
pytest.deprecated_call(dep, 0)
|
||||
|
||||
def test_deprecated_call_ret():
|
||||
ret = py.test.deprecated_call(dep, 0)
|
||||
ret = pytest.deprecated_call(dep, 0)
|
||||
assert ret == 42
|
||||
|
||||
def test_deprecated_call_preserves():
|
||||
@@ -73,9 +73,9 @@ def test_deprecated_call_preserves():
|
||||
|
||||
def test_deprecated_explicit_call_raises():
|
||||
pytest.raises(AssertionError,
|
||||
"py.test.deprecated_call(dep_explicit, 3)")
|
||||
"pytest.deprecated_call(dep_explicit, 3)")
|
||||
|
||||
def test_deprecated_explicit_call():
|
||||
py.test.deprecated_call(dep_explicit, 0)
|
||||
py.test.deprecated_call(dep_explicit, 0)
|
||||
pytest.deprecated_call(dep_explicit, 0)
|
||||
pytest.deprecated_call(dep_explicit, 0)
|
||||
|
||||
|
||||
+18
-18
@@ -268,7 +268,7 @@ class BaseFunctionalTests:
|
||||
raise SystemExit(42)
|
||||
""")
|
||||
except SystemExit:
|
||||
py.test.fail("runner did not catch SystemExit")
|
||||
pytest.fail("runner did not catch SystemExit")
|
||||
rep = reports[1]
|
||||
assert rep.failed
|
||||
assert rep.when == "call"
|
||||
@@ -280,10 +280,10 @@ class BaseFunctionalTests:
|
||||
def test_func():
|
||||
raise pytest.exit.Exception()
|
||||
""")
|
||||
except py.test.exit.Exception:
|
||||
except pytest.exit.Exception:
|
||||
pass
|
||||
else:
|
||||
py.test.fail("did not raise")
|
||||
pytest.fail("did not raise")
|
||||
|
||||
class TestExecutionNonForked(BaseFunctionalTests):
|
||||
def getrunner(self):
|
||||
@@ -300,14 +300,14 @@ class TestExecutionNonForked(BaseFunctionalTests):
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
else:
|
||||
py.test.fail("did not raise")
|
||||
pytest.fail("did not raise")
|
||||
|
||||
class TestExecutionForked(BaseFunctionalTests):
|
||||
pytestmark = pytest.mark.skipif("not hasattr(os, 'fork')")
|
||||
|
||||
def getrunner(self):
|
||||
# XXX re-arrange this test to live in pytest-xdist
|
||||
xplugin = py.test.importorskip("xdist.plugin")
|
||||
xplugin = pytest.importorskip("xdist.plugin")
|
||||
return xplugin.forked_run_report
|
||||
|
||||
def test_suicide(self, testdir):
|
||||
@@ -417,15 +417,15 @@ def test_outcomeexception_exceptionattributes():
|
||||
|
||||
def test_pytest_exit():
|
||||
try:
|
||||
py.test.exit("hello")
|
||||
except py.test.exit.Exception:
|
||||
pytest.exit("hello")
|
||||
except pytest.exit.Exception:
|
||||
excinfo = py.code.ExceptionInfo()
|
||||
assert excinfo.errisinstance(KeyboardInterrupt)
|
||||
|
||||
def test_pytest_fail():
|
||||
try:
|
||||
py.test.fail("hello")
|
||||
except py.test.fail.Exception:
|
||||
pytest.fail("hello")
|
||||
except pytest.fail.Exception:
|
||||
excinfo = py.code.ExceptionInfo()
|
||||
s = excinfo.exconly(tryshort=True)
|
||||
assert s.startswith("Failed")
|
||||
@@ -454,45 +454,45 @@ def test_exception_printing_skip():
|
||||
assert s.startswith("Skipped")
|
||||
|
||||
def test_importorskip():
|
||||
importorskip = py.test.importorskip
|
||||
importorskip = pytest.importorskip
|
||||
def f():
|
||||
importorskip("asdlkj")
|
||||
try:
|
||||
sys = importorskip("sys") # noqa
|
||||
assert sys == py.std.sys
|
||||
#path = py.test.importorskip("os.path")
|
||||
#path = pytest.importorskip("os.path")
|
||||
#assert path == py.std.os.path
|
||||
excinfo = pytest.raises(pytest.skip.Exception, f)
|
||||
path = py.path.local(excinfo.getrepr().reprcrash.path)
|
||||
# check that importorskip reports the actual call
|
||||
# in this test the test_runner.py file
|
||||
assert path.purebasename == "test_runner"
|
||||
pytest.raises(SyntaxError, "py.test.importorskip('x y z')")
|
||||
pytest.raises(SyntaxError, "py.test.importorskip('x=y')")
|
||||
pytest.raises(SyntaxError, "pytest.importorskip('x y z')")
|
||||
pytest.raises(SyntaxError, "pytest.importorskip('x=y')")
|
||||
mod = py.std.types.ModuleType("hello123")
|
||||
mod.__version__ = "1.3"
|
||||
sys.modules["hello123"] = mod
|
||||
pytest.raises(pytest.skip.Exception, """
|
||||
py.test.importorskip("hello123", minversion="1.3.1")
|
||||
pytest.importorskip("hello123", minversion="1.3.1")
|
||||
""")
|
||||
mod2 = pytest.importorskip("hello123", minversion="1.3")
|
||||
assert mod2 == mod
|
||||
except pytest.skip.Exception:
|
||||
print(py.code.ExceptionInfo())
|
||||
py.test.fail("spurious skip")
|
||||
pytest.fail("spurious skip")
|
||||
|
||||
def test_importorskip_imports_last_module_part():
|
||||
ospath = py.test.importorskip("os.path")
|
||||
ospath = pytest.importorskip("os.path")
|
||||
assert os.path == ospath
|
||||
|
||||
|
||||
def test_pytest_cmdline_main(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import py
|
||||
import pytest
|
||||
def test_hello():
|
||||
assert 1
|
||||
if __name__ == '__main__':
|
||||
py.test.cmdline.main([__file__])
|
||||
pytest.cmdline.main([__file__])
|
||||
""")
|
||||
import subprocess
|
||||
popen = subprocess.Popen([sys.executable, str(p)], stdout=subprocess.PIPE)
|
||||
|
||||
@@ -54,7 +54,7 @@ class SessionTests:
|
||||
out = failed[0].longrepr.reprcrash.message
|
||||
if not out.find("DID NOT RAISE") != -1:
|
||||
print(out)
|
||||
py.test.fail("incorrect raises() output")
|
||||
pytest.fail("incorrect raises() output")
|
||||
|
||||
def test_generator_yields_None(self, testdir):
|
||||
reprec = testdir.inline_runsource("""
|
||||
@@ -127,7 +127,7 @@ class SessionTests:
|
||||
try:
|
||||
reprec = testdir.inline_run(testdir.tmpdir)
|
||||
except pytest.skip.Exception:
|
||||
py.test.fail("wrong skipped caught")
|
||||
pytest.fail("wrong skipped caught")
|
||||
reports = reprec.getreports("pytest_collectreport")
|
||||
assert len(reports) == 1
|
||||
assert reports[0].skipped
|
||||
|
||||
@@ -27,9 +27,9 @@ def test_funcarg(testdir):
|
||||
assert bn == "qwe__abc"
|
||||
|
||||
def test_ensuretemp(recwarn):
|
||||
#py.test.deprecated_call(py.test.ensuretemp, 'hello')
|
||||
d1 = py.test.ensuretemp('hello')
|
||||
d2 = py.test.ensuretemp('hello')
|
||||
#pytest.deprecated_call(pytest.ensuretemp, 'hello')
|
||||
d1 = pytest.ensuretemp('hello')
|
||||
d2 = pytest.ensuretemp('hello')
|
||||
assert d1 == d2
|
||||
assert d1.check(dir=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user