port some acceptance tests over to copy_example
This commit is contained in:
parent
0672bc633f
commit
e860ff7299
|
@ -635,7 +635,10 @@ class Testdir(object):
|
|||
def copy_example(self, name):
|
||||
example_dir = self.request.config.getini("pytester_example_dir")
|
||||
example_path = self.request.config.rootdir.join(example_dir, name)
|
||||
example_path.copy(self.tmpdir.join(example_path.basename))
|
||||
if example_path.isdir() and not example_path.join("__init__.py").isfile():
|
||||
example_path.copy(self.tmpdir)
|
||||
else:
|
||||
example_path.copy(self.tmpdir.join(example_path.basename))
|
||||
|
||||
Session = Session
|
||||
|
||||
|
|
|
@ -14,13 +14,7 @@ from _pytest.main import EXIT_NOTESTSCOLLECTED, EXIT_USAGEERROR
|
|||
|
||||
class TestGeneralUsage(object):
|
||||
def test_config_error(self, testdir):
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
def pytest_configure(config):
|
||||
import pytest
|
||||
raise pytest.UsageError("hello")
|
||||
"""
|
||||
)
|
||||
testdir.copy_example("conftest_usageerror/conftest.py")
|
||||
result = testdir.runpytest(testdir.tmpdir)
|
||||
assert result.ret != 0
|
||||
result.stderr.fnmatch_lines(["*ERROR: hello"])
|
||||
|
@ -170,18 +164,7 @@ class TestGeneralUsage(object):
|
|||
result.stdout.fnmatch_lines(["*1 skip*"])
|
||||
|
||||
def test_issue88_initial_file_multinodes(self, testdir):
|
||||
testdir.makeconftest(
|
||||
"""
|
||||
import pytest
|
||||
class MyFile(pytest.File):
|
||||
def collect(self):
|
||||
return [MyItem("hello", parent=self)]
|
||||
def pytest_collect_file(path, parent):
|
||||
return MyFile(path, parent)
|
||||
class MyItem(pytest.Item):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
testdir.copy_example("issue88_initial_file_multinodes")
|
||||
p = testdir.makepyfile("def test_hello(): pass")
|
||||
result = testdir.runpytest(p, "--collect-only")
|
||||
result.stdout.fnmatch_lines(["*MyFile*test_issue88*", "*Module*test_issue88*"])
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
def pytest_configure(config):
|
||||
import pytest
|
||||
|
||||
raise pytest.UsageError("hello")
|
|
@ -0,0 +1,14 @@
|
|||
import pytest
|
||||
|
||||
|
||||
class MyFile(pytest.File):
|
||||
def collect(self):
|
||||
return [MyItem("hello", parent=self)]
|
||||
|
||||
|
||||
def pytest_collect_file(path, parent):
|
||||
return MyFile(path, parent)
|
||||
|
||||
|
||||
class MyItem(pytest.Item):
|
||||
pass
|
|
@ -0,0 +1,2 @@
|
|||
def test_hello():
|
||||
pass
|
|
@ -0,0 +1,3 @@
|
|||
def test_510(testdir):
|
||||
testdir.copy_example("issue_519.py")
|
||||
testdir.runpytest("issue_519.py")
|
Loading…
Reference in New Issue