forked from freeipa-pr-ci2/freeipa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pytest conftest.py and drop pytest.ini
Let's replace some ugly hacks with proper pytest conftest.py hooks. Test initialization of ipalib.api is now handled in pytest_cmdline_main(). Pytest plugins, markers and ignores are also moved into conftest.py. Additional guards make it possible to run tests without ipaserver installed. I added confcutdir to ensure that pytest does not leave our project space. Pytest used pytest.ini or setup.py before but pytest.ini is gone. Signed-off-by: Christian Heimes <[email protected]> Reviewed-By: Milan Kubik <[email protected]>
- Loading branch information
1 parent
3387734
commit 1e06a51
Showing
8 changed files
with
90 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license | ||
# | ||
from __future__ import print_function | ||
|
||
from ipalib import api | ||
from ipalib.cli import cli_plugins | ||
try: | ||
import ipaserver | ||
except ImportError: | ||
ipaserver = None | ||
|
||
|
||
pytest_plugins = [ | ||
'ipatests.pytest_plugins.additional_config', | ||
'ipatests.pytest_plugins.beakerlib', | ||
'ipatests.pytest_plugins.declarative', | ||
'ipatests.pytest_plugins.nose_compat', | ||
] | ||
# The integration plugin is not available in client-only builds. | ||
if ipaserver is not None: | ||
pytest_plugins.append('ipatests.pytest_plugins.integration') | ||
|
||
|
||
MARKERS = [ | ||
'tier0: basic unit tests and critical functionality', | ||
'tier1: functional API tests', | ||
'cs_acceptance: Acceptance test suite for Dogtag Certificate Server', | ||
'ds_acceptance: Acceptance test suite for 389 Directory Server', | ||
] | ||
|
||
|
||
NO_RECURSE_DIRS = [ | ||
# build directories | ||
'ipaclient/build', | ||
'ipalib/build', | ||
'ipaplatform/build', | ||
'ipapython/build', | ||
'ipaserver/build', | ||
'ipatests/build', | ||
# install/share/wsgi.py | ||
'install/share' | ||
] | ||
|
||
|
||
def pytest_configure(config): | ||
# add pytest markers | ||
for marker in MARKERS: | ||
config.addinivalue_line('markers', marker) | ||
|
||
# do not recurse into build directories or install/share directory. | ||
for norecursedir in NO_RECURSE_DIRS: | ||
config.addinivalue_line('norecursedirs', norecursedir) | ||
|
||
# load test classes with these prefixes. | ||
# addinivalue_line() adds duplicated entries. | ||
python_classes = config.getini('python_classes') | ||
for value in ['test_', 'Test']: | ||
if value not in python_classes: | ||
python_classes.append(value) | ||
|
||
# set default JUnit prefix | ||
if config.option.junitprefix is None: | ||
config.option.junitprefix = 'ipa' | ||
|
||
# always run doc tests | ||
config.option.doctestmodules = True | ||
|
||
|
||
def pytest_cmdline_main(config): | ||
api.bootstrap( | ||
context=u'cli', in_server=False, in_tree=True, fallback=False | ||
) | ||
for klass in cli_plugins: | ||
api.add_plugin(klass) | ||
api.finalize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#! /bin/bash | ||
|
||
#!/bin/bash | ||
set -ex | ||
IPA_UNIT_TEST_MODE=cli_test PYTHONPATH=.:$PYTHONPATH py.test "$@" | ||
|
||
SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
||
PYTHONPATH=$SCRIPTDIR:$PYTHONPATH py.test --confcutdir="$SCRIPTDIR" "$@" |
This file was deleted.
Oops, something went wrong.