blob: 59b7d3a95adb3391fe265bcab6559f2c4c96c3fe [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pytest
@pytest.fixture(autouse=True)
def run_examples(request):
run_examples = request.config.getoption("--examples")
if request.node.get_closest_marker('examples'):
if not run_examples:
pytest.skip('skipped examples: --examples is not passed')
@pytest.fixture(autouse=True)
def skip_if_no_cext(request):
skip = False
try:
from pyignite import _cutils
except ImportError:
if request.config.getoption('--force-cext'):
pytest.fail("C extension failed to build, fail test because of --force-cext is set.")
return
skip = True
if skip and request.node.get_closest_marker('skip_if_no_cext'):
pytest.skip('skipped c extensions test, c extension is not available.')
def pytest_addoption(parser):
parser.addoption(
'--examples',
action='store_true',
help='check if examples can be run',
)
parser.addoption(
'--force-cext',
action='store_true',
help='check if examples can be run',
)
def pytest_configure(config):
marker_docs = [
"skip_if_no_cext: mark test to run only if c extension is available",
"examples: mark test to run only if --examples are set"
]
for marker_doc in marker_docs:
config.addinivalue_line("markers", marker_doc)