def run(self):
import pytest
rcode = pytest.main(self.test_args)
sys.exit(rcode)
python类main()的实例源码
def run_tests(self):
import pytest
errcode = pytest.main(self.test_args)
sys.exit(errcode)
def run_tests(self):
"""Customized run"""
# deferred import
import pytest
# run pytest with empty array so pytest.ini takes complete control
# need to use [] because of https://github.com/pytest-dev/pytest/issues/1110
errno = pytest.main([])
sys.exit(errno)
#
# Main logic
#
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def run_tests(self):
import pytest
errcode = pytest.main(self.test_args)
sys.exit(errcode)
def run_tests(self):
import pytest
sys.exit(pytest.main(self.pytest_args))
def run_tests(self):
# Import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
# Read the long description from readme.rst
def run_tests(self):
import pytest
exit_code = pytest.main(self.pytest_args)
sys.exit(exit_code)
def run_tests(self):
import shlex
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(shlex.split(self.pytest_args))
sys.exit(errno)
def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def pytest_addoption(parser):
# group = parser.getgroup("pytester", "pytester (self-tests) options")
parser.addoption('--lsof',
action="store_true", dest="lsof", default=False,
help=("run FD checks if lsof is available"))
parser.addoption('--runpytest', default="inprocess", dest="runpytest",
choices=("inprocess", "subprocess", ),
help=("run pytest sub runs in tests using an 'inprocess' "
"or 'subprocess' (python -m main) method"))
def inline_genitems(self, *args):
"""Run ``pytest.main(['--collectonly'])`` in-process.
Retuns a tuple of the collected items and a
:py:class:`HookRecorder` instance.
This runs the :py:func:`pytest.main` function to run all of
pytest inside the test process itself like
:py:meth:`inline_run`. However the return value is a tuple of
the collection items and a :py:class:`HookRecorder` instance.
"""
rec = self.inline_run("--collect-only", *args)
items = [x.item for x in rec.getcalls("pytest_itemcollected")]
return items, rec
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)
def run_tests(self):
#import here, cause outside the eggs aren't loaded
import coverage
cov = coverage.Coverage()
cov.start()
import pytest
errno = pytest.main(self.pytest_args)
cov.stop()
cov.save()
sys.exit(errno)
def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)
def run_tests():
import pytest
pytest.main(tests_directory_path)
create_database()
def main():
import os
import sys
from ptvsd.visualstudio_py_debugger import DONT_DEBUG, DEBUG_ENTRYPOINTS, get_code
from ptvsd.attach_server import DEFAULT_PORT, enable_attach, wait_for_attach
sys.path[0] = os.getcwd()
os.chdir(sys.argv[1])
secret = sys.argv[2]
port = int(sys.argv[3])
testFx = sys.argv[4]
args = sys.argv[5:]
DONT_DEBUG.append(os.path.normcase(__file__))
DEBUG_ENTRYPOINTS.add(get_code(main))
enable_attach(secret, ('127.0.0.1', port), redirect_output = False)
sys.stdout.flush()
print('READY')
sys.stdout.flush()
wait_for_attach()
try:
if testFx == 'pytest':
import pytest
pytest.main(args)
else:
import nose
nose.run(argv=args)
sys.exit()
finally:
pass
def test(ctx, watch=False, last_failing=False):
"""Run the tests.
Note: --watch requires pytest-xdist to be installed.
"""
import pytest
flake(ctx)
args = []
if watch:
args.append('-f')
if last_failing:
args.append('--lf')
retcode = pytest.main(args)
sys.exit(retcode)