/
conftest.py
43 lines (32 loc) · 925 Bytes
/
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
#!/usr/bin/env python
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
import argparse
import ast
import pytest
def pytest_addoption(parser):
parser.addoption(
"--benchmark-py-file",
action="store",
type=argparse.FileType("r"),
help="Benchmark Dlint against this Python file."
)
parser.addoption(
"--benchmark-group-base-class",
action="store_true",
help="Group Dlint benchmark results by base class."
)
@pytest.fixture
def benchmark_py_file(request):
fd = request.config.getoption("--benchmark-py-file", skip=True)
if fd.tell() > 0:
# Read calls from previous tests exhaust the file descriptor
fd.seek(0)
return ast.parse(fd.read())
@pytest.fixture
def benchmark_group_base_class(request):
return request.config.getoption("--benchmark-group-base-class")