Python matplotlib._called_from_pytest() Examples
The following are 23
code examples of matplotlib._called_from_pytest().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: conftest.py From coffeegrindsize with MIT License | 5 votes |
def pytest_unconfigure(config): matplotlib._called_from_pytest = False
Example #2
Source File: determinism.py From twitter-stock-recommendation with MIT License | 5 votes |
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
Example #3
Source File: determinism.py From twitter-stock-recommendation with MIT License | 5 votes |
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]
Example #4
Source File: conftest.py From twitter-stock-recommendation with MIT License | 5 votes |
def pytest_unconfigure(config): matplotlib._called_from_pytest = False
Example #5
Source File: conftest.py From twitter-stock-recommendation with MIT License | 5 votes |
def pytest_configure(config): matplotlib.use('agg') matplotlib._called_from_pytest = True matplotlib._init_tests()
Example #6
Source File: test_backend_svg.py From twitter-stock-recommendation with MIT License | 5 votes |
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]
Example #7
Source File: determinism.py From CogAlg with MIT License | 5 votes |
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
Example #8
Source File: determinism.py From CogAlg with MIT License | 5 votes |
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]
Example #9
Source File: conftest.py From CogAlg with MIT License | 5 votes |
def pytest_unconfigure(config): matplotlib._called_from_pytest = False
Example #10
Source File: conftest.py From CogAlg with MIT License | 5 votes |
def pytest_configure(config): matplotlib.use('agg', force=True) matplotlib._called_from_pytest = True matplotlib._init_tests()
Example #11
Source File: determinism.py From coffeegrindsize with MIT License | 5 votes |
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
Example #12
Source File: determinism.py From coffeegrindsize with MIT License | 5 votes |
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]
Example #13
Source File: conftest.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def pytest_configure(config): matplotlib.use('agg', force=True) matplotlib._called_from_pytest = True matplotlib._init_tests()
Example #14
Source File: conftest.py From coffeegrindsize with MIT License | 5 votes |
def pytest_configure(config): matplotlib.use('agg', force=True) matplotlib._called_from_pytest = True matplotlib._init_tests()
Example #15
Source File: test_backend_svg.py From coffeegrindsize with MIT License | 5 votes |
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]
Example #16
Source File: determinism.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #17
Source File: determinism.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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]
Example #18
Source File: conftest.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def pytest_unconfigure(config): matplotlib._called_from_pytest = False
Example #19
Source File: conftest.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def pytest_configure(config): matplotlib.use('agg', force=True) matplotlib._called_from_pytest = True matplotlib._init_tests()
Example #20
Source File: test_backend_svg.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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]
Example #21
Source File: determinism.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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
Example #22
Source File: determinism.py From GraphicDesignPatternByPython with MIT License | 5 votes |
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]
Example #23
Source File: conftest.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def pytest_unconfigure(config): matplotlib._called_from_pytest = False