当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib._called_from_pytest方法代码示例

本文整理汇总了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() 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:6,代码来源:conftest.py

示例2: pytest_unconfigure

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import _called_from_pytest [as 别名]
def pytest_unconfigure(config):
    matplotlib._called_from_pytest = False 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:conftest.py

示例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] 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:33,代码来源:determinism.py

示例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 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:34,代码来源:determinism.py

示例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] 
开发者ID:holzschu,项目名称:python3_ios,代码行数:32,代码来源:test_backend_svg.py

示例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] 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:32,代码来源:test_backend_svg.py

示例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() 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:6,代码来源:conftest.py

示例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] 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:33,代码来源:determinism.py

示例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 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:34,代码来源:determinism.py


注:本文中的matplotlib._called_from_pytest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。