本文整理匯總了Python中matplotlib._called_from_pytest方法的典型用法代碼示例。如果您正苦於以下問題:Python matplotlib._called_from_pytest方法的具體用法?Python matplotlib._called_from_pytest怎麽用?Python matplotlib._called_from_pytest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib
的用法示例。
在下文中一共展示了matplotlib._called_from_pytest方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pytest_configure
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def pytest_configure(config):
matplotlib.use('agg', force=True)
matplotlib._called_from_pytest = True
matplotlib._init_tests()
示例2: pytest_unconfigure
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def pytest_unconfigure(config):
matplotlib._called_from_pytest = False
示例3: _determinism_check
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def _determinism_check(objects='mhi', format="pdf", usetex=False):
"""
Output three times the same graphs and checks that the outputs are exactly
the same.
Parameters
----------
objects : str
contains characters corresponding to objects to be included in the test
document: 'm' for markers, 'h' for hatch patterns, 'i' for images. The
default value is "mhi", so that the test includes all these objects.
format : str
format string. The default value is "pdf".
"""
plots = []
for i in range(3):
result = subprocess.check_output([
sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use(%r); '
'from matplotlib.testing.determinism import _determinism_save;'
'_determinism_save(%r, %r, %r)'
% (format, objects, format, usetex)])
plots.append(result)
for p in plots[1:]:
if usetex:
if p != plots[0]:
pytest.skip("failed, maybe due to ghostscript timestamps")
else:
assert p == plots[0]
示例4: _determinism_source_date_epoch
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def _determinism_source_date_epoch(format, string, keyword=b"CreationDate"):
"""
Test SOURCE_DATE_EPOCH support. Output a document with the environment
variable SOURCE_DATE_EPOCH set to 2000-01-01 00:00 UTC and check that the
document contains the timestamp that corresponds to this date (given as an
argument).
Parameters
----------
format : str
format string, such as "pdf".
string : str
timestamp string for 2000-01-01 00:00 UTC.
keyword : bytes
a string to look at when searching for the timestamp in the document
(used in case the test fails).
"""
buff = subprocess.check_output([
sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use(%r); '
'from matplotlib.testing.determinism import _determinism_save;'
'_determinism_save(%r, %r)'
% (format, "", format)])
find_keyword = re.compile(b".*" + keyword + b".*")
key = find_keyword.search(buff)
if key:
print(key.group())
else:
print("Timestamp keyword (%s) not found!" % keyword)
assert string in buff
示例5: test_determinism
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def test_determinism(filename, usetex):
import sys
from subprocess import check_output, STDOUT, CalledProcessError
plots = []
for i in range(3):
# Using check_output and setting stderr to STDOUT will capture the real
# problem in the output property of the exception
try:
check_output(
[sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use("svg", force=True); '
'from matplotlib.tests.test_backend_svg '
'import _test_determinism_save;'
'_test_determinism_save(%r, %r)' % (filename, usetex)],
stderr=STDOUT)
except CalledProcessError as e:
# it's easier to use utf8 and ask for forgiveness than try
# to figure out what the current console has as an
# encoding :-/
print(e.output.decode(encoding="utf-8", errors="ignore"))
raise e
else:
with open(filename, 'rb') as fd:
plots.append(fd.read())
finally:
os.unlink(filename)
for p in plots[1:]:
assert p == plots[0]
示例6: test_determinism
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def test_determinism(filename, usetex):
import sys
from subprocess import check_output, STDOUT, CalledProcessError
plots = []
for i in range(3):
# Using check_output and setting stderr to STDOUT will capture the real
# problem in the output property of the exception
try:
check_output(
[sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use("svg"); '
'from matplotlib.tests.test_backend_svg '
'import _test_determinism_save;'
'_test_determinism_save(%r, %r)' % (filename, usetex)],
stderr=STDOUT)
except CalledProcessError as e:
# it's easier to use utf8 and ask for forgiveness than try
# to figure out what the current console has as an
# encoding :-/
print(e.output.decode(encoding="utf-8", errors="ignore"))
raise e
else:
with open(filename, 'rb') as fd:
plots.append(fd.read())
finally:
os.unlink(filename)
for p in plots[1:]:
assert p == plots[0]
示例7: pytest_configure
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def pytest_configure(config):
matplotlib.use('agg')
matplotlib._called_from_pytest = True
matplotlib._init_tests()
示例8: _determinism_check
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def _determinism_check(objects='mhi', format="pdf", usetex=False):
"""
Output three times the same graphs and checks that the outputs are exactly
the same.
Parameters
----------
objects : str
contains characters corresponding to objects to be included in the test
document: 'm' for markers, 'h' for hatch patterns, 'i' for images. The
default value is "mhi", so that the test includes all these objects.
format : str
format string. The default value is "pdf".
"""
plots = []
for i in range(3):
result = check_output([sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use(%r); '
'from matplotlib.testing.determinism '
'import _determinism_save;'
'_determinism_save(%r,%r,%r)'
% (format, objects, format, usetex)])
plots.append(result)
for p in plots[1:]:
if usetex:
if p != plots[0]:
pytest.skip("failed, maybe due to ghostscript timestamps")
else:
assert p == plots[0]
示例9: _determinism_source_date_epoch
# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import _called_from_pytest [as 別名]
def _determinism_source_date_epoch(format, string, keyword=b"CreationDate"):
"""
Test SOURCE_DATE_EPOCH support. Output a document with the environment
variable SOURCE_DATE_EPOCH set to 2000-01-01 00:00 UTC and check that the
document contains the timestamp that corresponds to this date (given as an
argument).
Parameters
----------
format : str
format string, such as "pdf".
string : str
timestamp string for 2000-01-01 00:00 UTC.
keyword : bytes
a string to look at when searching for the timestamp in the document
(used in case the test fails).
"""
buff = check_output([sys.executable, '-R', '-c',
'import matplotlib; '
'matplotlib._called_from_pytest = True; '
'matplotlib.use(%r); '
'from matplotlib.testing.determinism '
'import _determinism_save;'
'_determinism_save(%r,%r)'
% (format, "", format)])
find_keyword = re.compile(b".*" + keyword + b".*")
key = find_keyword.search(buff)
if key:
print(key.group())
else:
print("Timestamp keyword (%s) not found!" % keyword)
assert string in buff