This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch tristan/remove-plugins in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit c7020c34c241634684794154e7aa5115dded8a6d Author: Tristan van Berkom <[email protected]> AuthorDate: Tue Mar 29 15:45:27 2022 +0900 tests/testutils/site.py: Move the pip_sample_plugins() check to a common site.py As we will be using the sample plugins package to carry some plugins we want to use for general purpose testing of the API surface throughout buildstream, we'll need to have this in a shared location. --- tests/plugins/loading.py | 34 +++------------------------------- tests/testutils/site.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py index e0663c5..2863133 100644 --- a/tests/plugins/loading.py +++ b/tests/plugins/loading.py @@ -14,6 +14,9 @@ from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream._testing import cli # pylint: disable=unused-import from buildstream import _yaml +from tests.testutils.site import pip_sample_packages # pylint: disable=unused-import +from tests.testutils.site import SAMPLE_PACKAGES_SKIP_REASON + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "loading") @@ -43,37 +46,6 @@ def setup_element(project_path, plugin_type, plugin_name): _yaml.roundtrip_dump(element, element_path) -# This function is used for pytest skipif() expressions. -# -# Tests which require our plugins in tests/plugins/pip-samples need -# to check if these plugins are installed, they are only guaranteed -# to be installed when running tox, but not when using pytest directly -# to test that BuildStream works when integrated in your system. -# -def pip_sample_packages(): - import pkg_resources - - required = {"sample-plugins"} - installed = {pkg.key for pkg in pkg_resources.working_set} # pylint: disable=not-an-iterable - missing = required - installed - - if missing: - return False - - return True - - -SAMPLE_PACKAGES_SKIP_REASON = """ -The sample plugins package used to test pip plugin origins is not installed. - -This is usually tested automatically with `tox`, if you are running -`pytest` directly then you can install these plugins directly using pip. - -The plugins are located in the tests/plugins/sample-plugins directory -of your BuildStream checkout. -""" - - #################################################### # Tests # #################################################### diff --git a/tests/testutils/site.py b/tests/testutils/site.py new file mode 100644 index 0000000..d626cfe --- /dev/null +++ b/tests/testutils/site.py @@ -0,0 +1,29 @@ +# This function is used for pytest skipif() expressions. +# +# Tests which require our plugins in tests/plugins/pip-samples need +# to check if these plugins are installed, they are only guaranteed +# to be installed when running tox, but not when using pytest directly +# to test that BuildStream works when integrated in your system. +# +def pip_sample_packages(): + import pkg_resources + + required = {"sample-plugins"} + installed = {pkg.key for pkg in pkg_resources.working_set} # pylint: disable=not-an-iterable + missing = required - installed + + if missing: + return False + + return True + + +SAMPLE_PACKAGES_SKIP_REASON = """ +The sample plugins package used to test pip plugin origins is not installed. + +This is usually tested automatically with `tox`, if you are running +`pytest` directly then you can install these plugins directly using pip. + +The plugins are located in the tests/plugins/sample-plugins directory +of your BuildStream checkout. +"""
