Expose templated source tests
Make it possible for plugin authors to leverage buildstream's suite of generic source tests.
In order to run a custom source type through this test suite a plugin author must: Adding the following code into a conftest.py in a project's test suite will allow pytest to discover the suite of source tests.
import pytest from buildstream.plugintestutils import sourcetests_collection_hook # This hook enables pytest to collect the templated source tests from # buildstream.plugintestutils def pytest_sessionstart(session): sourcetests_collection_hook(session)
The tests will then be discovered as part of whichever test package contains this code in a conftest.py.
buildstream.plugintestutils.Repo, implementing the functionality appropriate to their source plugin
register_repo_kindmethod provided by buildstream.plugintestutils to register the new
Repotype with the test suite. This must be done somewhere which willl be executed prior to pytest performing test collection, probably in a
__init__.pyfile at an appropriate location(s) in the test suite.
Changes proposed in this merge request:
- Expose Repo class as part of the buildstream.plugintestutils API
- Move templated source tests from tests.sources.generic into buildstream.plugintestutil._sourcetests.
- Provide an easy way to register source types to run though the templated test suites
This merge request, when approved, will close issue/bug: #944 (closed)
This MR is most easily reviewed commit by commit. The majority of the files changed are ammending imports due to the movement of repo.py from tests.testutils to buildstream.plugintestutils