當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。