-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconftest.py
51 lines (46 loc) · 1.41 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
import os
import sys
import pytest
import numpy
import pandas
import matplotlib
import subprocess
import glob
import json
import shutil
from collections import Counter
from collections import OrderedDict
from skimage import io
from tempfile import TemporaryDirectory
try:
from pyspark.sql import SparkSession
except ImportError:
pass # so the environment without spark doesn't break
@pytest.fixture(autouse=True)
def add_libraries(doctest_namespace):
"""Definition of doctest namespace.
See `more information <https://docs.pytest.org/en/latest/doctest.html#the-doctest-namespace-fixture>`
"""
doctest_namespace["os"] = os
doctest_namespace["sys"] = sys
doctest_namespace["np"] = numpy
doctest_namespace["pd"] = pandas
doctest_namespace["subprocess"] = subprocess
doctest_namespace["glob"] = glob
doctest_namespace["json"] = json
doctest_namespace["shutil"] = shutil
doctest_namespace["Counter"] = Counter
doctest_namespace["OrderedDict"] = OrderedDict
doctest_namespace["io"] = io
doctest_namespace["TemporaryDirectory"] = TemporaryDirectory
doctest_namespace["matplotlib"] = matplotlib
try:
spark = (
SparkSession.builder.appName("test pybase")
.master("local[*]")
.config("spark.driver.memory", "4g")
.getOrCreate()
)
except NameError:
spark = None
doctest_namespace["spark"] = spark