-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconftest.py
78 lines (65 loc) · 2.97 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- coding: utf-8 -*-
"""
*******************
tests.conftest
*******************
Utility functions that are used to configure Py.Test context.
"""
import os
import pytest
def pytest_addoption(parser):
"""Define options that the parser looks for in the command-line.
Pattern to use::
parser.addoption("--cli-option",
action="store",
default=None,
help="cli-option: help text goes here")
"""
parser.addoption("--inputs",
action="store",
default="/home/travis/build/highcharts-for-python/highcharts-maps/tests/input_files",
help=("inputs: the absolute path to the directory where input"
" files can be found"))
parser.addoption("--downloads",
action="store",
default="true",
help=("downloads: set to 'false' to disable tests of chart export "
"via the Highsoft-provided Export Server."))
parser.addoption("--create-output-directory",
action = "store",
default = "true",
help=("create-output-directory: set to 'false' to error if the output "
"directory does not exist, otherwise creates it."))
parser.addoption("--pyspark",
action="store",
default="false",
help=("pyspark: set to 'false' to disable tests of pyspark-related"
" functionality, or 'true' to enable those tests. Defaults to"
" 'false'"))
parser.addoption("--openai",
action="store",
default="none",
help=("openai: The API key to use to authenticate against OpenAI."))
parser.addoption('--disable-ai',
action='store',
default='true',
help=('disable-ai: set to "false" to enable tests of the AI'))
parser.addoption('--pandas',
action = 'store',
default = os.getenv('ENABLE_PANDAS', 'true'),
help=('pandas: set to "false" to disable tests of pandas-related'))
def pytest_runtest_makereport(item, call):
"""Connect current incremental test to its preceding parent."""
# pylint: disable=W0212
if "incremental" in item.keywords:
if call.excinfo is not None:
parent = item.parent
parent._previousfailed = item
def pytest_runtest_setup(item):
"""Fail test if preceding incremental test failed."""
if "incremental" in item.keywords:
previousfailed = getattr(item.parent, "_previousfailed", None)
if previousfailed is not None:
pytest.xfail(
"previous test failed (%s) for reason: %s" % (previousfailed.name,
previousfailed))