Run the unit tests before the integration tests

This commit is contained in:
Donald Stufft 2014-06-30 20:00:35 -04:00
parent 4f8632894a
commit 68c0b472a7
3 changed files with 39 additions and 7 deletions

View File

@ -6,11 +6,16 @@ set -x
# our tests use.
export LC_CTYPE=en_US.UTF-8
# Run the unit tests
tox -- -m unit
# Run our integration tests, typically with pytest-xdist to speed things up
# except on Python 3.2 where it doesn't work quite right.
case $TOXENV in
py32)
tox
tox -- -m integration
;;
*)
tox -- -n 8
tox -- -m integration -n 8
;;
esac

View File

@ -10,6 +10,33 @@ from tests.lib.scripttest import PipTestEnvironment
from tests.lib.venv import VirtualEnvironment
def pytest_collection_modifyitems(items):
for item in items:
module_path = os.path.relpath(
item.module.__file__,
os.path.commonprefix([__file__, item.module.__file__]),
)
if (module_path.startswith("functional/")
or module_path.startswith("integration/")
or module_path.startswith("lib/")):
item.add_marker(pytest.mark.integration)
elif module_path.startswith("unit/"):
item.add_marker(pytest.mark.unit)
# We don't want to allow using the script resource if this is a
# unit test, as unit tests should not need all that heavy lifting
if set(getattr(item, "funcargnames", [])) & set(["script"]):
raise RuntimeError(
"Cannot use the ``script`` funcarg in a unit test: "
"(filename = {0}, item = {1})".format(module_path, item)
)
else:
raise RuntimeError(
"Unknown test type (filename = {0})".format(module_path)
)
@pytest.fixture
def tmpdir(request):
"""

View File

@ -239,17 +239,17 @@ class Tests_get_installed_distributions:
assert len(dists) == 0
def test_find_command_folder_in_path(script):
def test_find_command_folder_in_path(tmpdir):
"""
If a folder named e.g. 'git' is in PATH, and find_command is looking for
the 'git' executable, it should not match the folder, but rather keep
looking.
"""
script.scratch_path.join("path_one").mkdir()
path_one = script.scratch_path / 'path_one'
tmpdir.join("path_one").mkdir()
path_one = tmpdir / 'path_one'
path_one.join("foo").mkdir()
script.scratch_path.join("path_two").mkdir()
path_two = script.scratch_path / 'path_two'
tmpdir.join("path_two").mkdir()
path_two = tmpdir / 'path_two'
path_two.join("foo").write("# nothing")
found_path = find_command('foo', map(str, [path_one, path_two]))
assert found_path == path_two / 'foo'