Debian Codegraph @

tests/conftest.py

raw
1 #
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 #
14 import pytest
15
16 from buildstream._testing import sourcetests_collection_hook
17 from buildstream._testing import register_repo_kind
18
19 from .testutils.repo import Bzr, Git
20
21
22 #################################################
23 # Implement pytest option #
24 #################################################
25 def pytest_addoption(parser):
26 parser.addoption(
27 "--integration",
28 action="store_true",
29 default=False,
30 help="Run integration tests",
31 )
32
33
34 def pytest_runtest_setup(item):
35 # Without --integration: skip tests not marked with 'integration'
36 if not item.config.getvalue("integration"):
37 if item.get_closest_marker("integration"):
38 pytest.skip("skipping integration test")
39
40
41 register_repo_kind("bzr", Bzr, "buildstream_plugins")
42 register_repo_kind("git", Git, "buildstream_plugins")
43
44
45 # This hook enables pytest to collect the templated source tests from
46 # buildstream._testing
47 def pytest_sessionstart(session):
48 sourcetests_collection_hook(session)