/usr/lib/python2.7/dist-packages/sunpy/conftest.py is in python-sunpy 0.8.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from __future__ import absolute_import, print_function
from functools import partial
import os
import tempfile
import json
# Force MPL to use non-gui backends for testing.
try:
import matplotlib
except ImportError:
pass
else:
matplotlib.use('Agg')
from sunpy.tests.hash import HASH_LIBRARY_NAME
from sunpy.tests.helpers import new_hash_library, figure_test_pngfiles
from sunpy.extern import six
import pytest
# Don't actually import pytest_remotedata because that can do things to the
# entrypoints code in pytest.
if six.PY2:
import imp
try:
imp.find_module('pytest_remotedata')
HAVE_REMOTEDATA = True
except ImportError:
HAVE_REMOTEDATA = False
else:
import importlib
remotedata_spec = importlib.util.find_spec("pytest_remotedata")
HAVE_REMOTEDATA = remotedata_spec is not None
def pytest_runtest_setup(item):
"""
pytest hook to skip all tests that have the mark 'online' if the
client is online (simply detected by checking whether http://www.google.com
can be requested).
"""
if isinstance(item, item.Function):
if 'remote_data' in item.keywords and not HAVE_REMOTEDATA:
pytest.skip("skipping remotedata tests as pytest-remotedata is not installed")
def pytest_unconfigure(config):
if len(figure_test_pngfiles) > 0:
tempdir = tempfile.mkdtemp(suffix="_figures")
# Rename each PNG with the name of the corresponding test
for test_name in figure_test_pngfiles:
os.rename(figure_test_pngfiles[test_name], os.path.join(tempdir, test_name + '.png'))
# Write the new hash library in JSON
hashfile = os.path.join(tempdir, HASH_LIBRARY_NAME)
with open(hashfile, 'w') as outfile:
json.dump(new_hash_library, outfile, sort_keys=True, indent=4, separators=(',', ': '))
print('All test files for figure hashes can be found in {0}'.format(tempdir))
print("The corresponding hash library is {0}".format(hashfile))
|