@@ -1,6 +1,9 @@
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
import pytest, py
|
||||
|
||||
import _pytest._code
|
||||
import py
|
||||
import pytest
|
||||
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
||||
|
||||
|
||||
@@ -598,13 +601,13 @@ class TestConftestCustomization:
|
||||
|
||||
def test_customized_pymakemodule_issue205_subdir(self, testdir):
|
||||
b = testdir.mkdir("a").mkdir("b")
|
||||
b.join("conftest.py").write(py.code.Source("""
|
||||
b.join("conftest.py").write(_pytest._code.Source("""
|
||||
def pytest_pycollect_makemodule(__multicall__):
|
||||
mod = __multicall__.execute()
|
||||
mod.obj.hello = "world"
|
||||
return mod
|
||||
"""))
|
||||
b.join("test_module.py").write(py.code.Source("""
|
||||
b.join("test_module.py").write(_pytest._code.Source("""
|
||||
def test_hello():
|
||||
assert hello == "world"
|
||||
"""))
|
||||
@@ -613,7 +616,7 @@ class TestConftestCustomization:
|
||||
|
||||
def test_customized_pymakeitem(self, testdir):
|
||||
b = testdir.mkdir("a").mkdir("b")
|
||||
b.join("conftest.py").write(py.code.Source("""
|
||||
b.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
@pytest.hookimpl(hookwrapper=True)
|
||||
def pytest_pycollect_makeitem():
|
||||
@@ -624,7 +627,7 @@ class TestConftestCustomization:
|
||||
for func in result:
|
||||
func._some123 = "world"
|
||||
"""))
|
||||
b.join("test_module.py").write(py.code.Source("""
|
||||
b.join("test_module.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -662,7 +665,7 @@ class TestConftestCustomization:
|
||||
def test_setup_only_available_in_subdir(testdir):
|
||||
sub1 = testdir.mkpydir("sub1")
|
||||
sub2 = testdir.mkpydir("sub2")
|
||||
sub1.join("conftest.py").write(py.code.Source("""
|
||||
sub1.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def pytest_runtest_setup(item):
|
||||
assert item.fspath.purebasename == "test_in_sub1"
|
||||
@@ -671,7 +674,7 @@ def test_setup_only_available_in_subdir(testdir):
|
||||
def pytest_runtest_teardown(item):
|
||||
assert item.fspath.purebasename == "test_in_sub1"
|
||||
"""))
|
||||
sub2.join("conftest.py").write(py.code.Source("""
|
||||
sub2.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def pytest_runtest_setup(item):
|
||||
assert item.fspath.purebasename == "test_in_sub2"
|
||||
@@ -787,7 +790,7 @@ class TestTracebackCutting:
|
||||
except ValueError:
|
||||
_, _, tb = sys.exc_info()
|
||||
|
||||
tb = py.code.Traceback(tb)
|
||||
tb = _pytest._code.Traceback(tb)
|
||||
assert isinstance(tb[-1].path, str)
|
||||
assert not filter_traceback(tb[-1])
|
||||
|
||||
@@ -810,7 +813,7 @@ class TestTracebackCutting:
|
||||
_, _, tb = sys.exc_info()
|
||||
|
||||
testdir.tmpdir.join('filter_traceback_entry_as_str.py').remove()
|
||||
tb = py.code.Traceback(tb)
|
||||
tb = _pytest._code.Traceback(tb)
|
||||
assert isinstance(tb[-1].path, str)
|
||||
assert filter_traceback(tb[-1])
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import pytest, py, sys
|
||||
from _pytest import python as funcargs
|
||||
from _pytest.python import FixtureLookupError
|
||||
from _pytest.pytester import get_public_names
|
||||
from textwrap import dedent
|
||||
|
||||
import _pytest._code
|
||||
import pytest
|
||||
import sys
|
||||
from _pytest import python as funcargs
|
||||
from _pytest.pytester import get_public_names
|
||||
from _pytest.python import FixtureLookupError
|
||||
|
||||
|
||||
def test_getfuncargnames():
|
||||
def f(): pass
|
||||
assert not funcargs.getfuncargnames(f)
|
||||
@@ -86,12 +90,12 @@ class TestFillFixtures:
|
||||
def test_conftest_funcargs_only_available_in_subdir(self, testdir):
|
||||
sub1 = testdir.mkpydir("sub1")
|
||||
sub2 = testdir.mkpydir("sub2")
|
||||
sub1.join("conftest.py").write(py.code.Source("""
|
||||
sub1.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def pytest_funcarg__arg1(request):
|
||||
pytest.raises(Exception, "request.getfuncargvalue('arg2')")
|
||||
"""))
|
||||
sub2.join("conftest.py").write(py.code.Source("""
|
||||
sub2.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def pytest_funcarg__arg2(request):
|
||||
pytest.raises(Exception, "request.getfuncargvalue('arg1')")
|
||||
@@ -156,7 +160,7 @@ class TestFillFixtures:
|
||||
return 'spam'
|
||||
""")
|
||||
pkg = testdir.mkpydir("pkg")
|
||||
pkg.join("conftest.py").write(py.code.Source("""
|
||||
pkg.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
@@ -164,7 +168,7 @@ class TestFillFixtures:
|
||||
return spam * 2
|
||||
"""))
|
||||
testfile = pkg.join("test_spam.py")
|
||||
testfile.write(py.code.Source("""
|
||||
testfile.write(_pytest._code.Source("""
|
||||
def test_spam(spam):
|
||||
assert spam == "spamspam"
|
||||
"""))
|
||||
@@ -258,7 +262,7 @@ class TestFillFixtures:
|
||||
return request.param
|
||||
""")
|
||||
subdir = testdir.mkpydir('subdir')
|
||||
subdir.join("conftest.py").write(py.code.Source("""
|
||||
subdir.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
@@ -266,7 +270,7 @@ class TestFillFixtures:
|
||||
return 'spam'
|
||||
"""))
|
||||
testfile = subdir.join("test_spam.py")
|
||||
testfile.write(py.code.Source("""
|
||||
testfile.write(_pytest._code.Source("""
|
||||
def test_spam(spam):
|
||||
assert spam == "spam"
|
||||
"""))
|
||||
@@ -312,7 +316,7 @@ class TestFillFixtures:
|
||||
return 'spam'
|
||||
""")
|
||||
subdir = testdir.mkpydir('subdir')
|
||||
subdir.join("conftest.py").write(py.code.Source("""
|
||||
subdir.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
|
||||
@pytest.fixture(params=[1, 2, 3])
|
||||
@@ -320,7 +324,7 @@ class TestFillFixtures:
|
||||
return request.param
|
||||
"""))
|
||||
testfile = subdir.join("test_spam.py")
|
||||
testfile.write(py.code.Source("""
|
||||
testfile.write(_pytest._code.Source("""
|
||||
params = {'spam': 1}
|
||||
|
||||
def test_spam(spam):
|
||||
@@ -609,7 +613,7 @@ class TestRequestBasic:
|
||||
def test_fixtures_sub_subdir_normalize_sep(self, testdir):
|
||||
# this tests that normalization of nodeids takes place
|
||||
b = testdir.mkdir("tests").mkdir("unit")
|
||||
b.join("conftest.py").write(py.code.Source("""
|
||||
b.join("conftest.py").write(_pytest._code.Source("""
|
||||
def pytest_funcarg__arg1():
|
||||
pass
|
||||
"""))
|
||||
@@ -1349,7 +1353,7 @@ class TestAutouseDiscovery:
|
||||
class TestAutouseManagement:
|
||||
def test_autouse_conftest_mid_directory(self, testdir):
|
||||
pkgdir = testdir.mkpydir("xyz123")
|
||||
pkgdir.join("conftest.py").write(py.code.Source("""
|
||||
pkgdir.join("conftest.py").write(_pytest._code.Source("""
|
||||
import pytest
|
||||
@pytest.fixture(autouse=True)
|
||||
def app():
|
||||
@@ -1357,7 +1361,7 @@ class TestAutouseManagement:
|
||||
sys._myapp = "hello"
|
||||
"""))
|
||||
t = pkgdir.ensure("tests", "test_app.py")
|
||||
t.write(py.code.Source("""
|
||||
t.write(_pytest._code.Source("""
|
||||
import sys
|
||||
def test_app():
|
||||
assert sys._myapp == "hello"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import pytest
|
||||
from _pytest import runner
|
||||
from _pytest import python
|
||||
from _pytest import runner
|
||||
|
||||
|
||||
class TestOEJSKITSpecials:
|
||||
def test_funcarg_non_pycollectobj(self, testdir): # rough jstests usage
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
|
||||
import pytest, py
|
||||
import _pytest._code
|
||||
import py
|
||||
import pytest
|
||||
from _pytest import python as funcargs
|
||||
|
||||
class TestMetafunc:
|
||||
@@ -838,11 +840,11 @@ class TestMetafuncFunctional:
|
||||
def test_generate_tests_only_done_in_subdir(self, testdir):
|
||||
sub1 = testdir.mkpydir("sub1")
|
||||
sub2 = testdir.mkpydir("sub2")
|
||||
sub1.join("conftest.py").write(py.code.Source("""
|
||||
sub1.join("conftest.py").write(_pytest._code.Source("""
|
||||
def pytest_generate_tests(metafunc):
|
||||
assert metafunc.function.__name__ == "test_1"
|
||||
"""))
|
||||
sub2.join("conftest.py").write(py.code.Source("""
|
||||
sub2.join("conftest.py").write(_pytest._code.Source("""
|
||||
def pytest_generate_tests(metafunc):
|
||||
assert metafunc.function.__name__ == "test_2"
|
||||
"""))
|
||||
|
||||
@@ -38,10 +38,11 @@ class TestRaises:
|
||||
testdir.makepyfile("""
|
||||
from __future__ import with_statement
|
||||
import py, pytest
|
||||
import _pytest._code
|
||||
|
||||
def test_simple():
|
||||
with pytest.raises(ZeroDivisionError) as excinfo:
|
||||
assert isinstance(excinfo, py.code.ExceptionInfo)
|
||||
assert isinstance(excinfo, _pytest._code.ExceptionInfo)
|
||||
1/0
|
||||
print (excinfo)
|
||||
assert excinfo.type == ZeroDivisionError
|
||||
|
||||
Reference in New Issue
Block a user