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


Python compare.comparable_formats函数代码示例

本文整理汇总了Python中matplotlib.testing.compare.comparable_formats函数的典型用法代码示例。如果您正苦于以下问题:Python comparable_formats函数的具体用法?Python comparable_formats怎么用?Python comparable_formats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了comparable_formats函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _mark_xfail_if_format_is_uncomparable

def _mark_xfail_if_format_is_uncomparable(extension):
    if isinstance(extension, str):
        will_fail = extension not in comparable_formats()
    else:
        # Extension might be a pytest marker instead of a plain string.
        will_fail = extension.args[0] not in comparable_formats()
    if will_fail:
        fail_msg = 'Cannot compare %s files on this system' % extension
        import pytest
        return pytest.mark.xfail(extension, reason=fail_msg, strict=False,
                                 raises=ImageComparisonFailure)
    else:
        return extension
开发者ID:mspacek,项目名称:matplotlib,代码行数:13,代码来源:decorators.py

示例2: test

    def test(self):
        baseline_dir, result_dir = _image_directories(self._func)

        for fignum, baseline in zip(plt.get_fignums(), self._baseline_images):
            for extension in self._extensions:
                will_fail = not extension in comparable_formats()
                if will_fail:
                    fail_msg = 'Cannot compare %s files on this system' % extension
                else:
                    fail_msg = 'No failure expected'

                orig_expected_fname = os.path.join(baseline_dir, baseline) + '.' + extension
                if extension == 'eps' and not os.path.exists(orig_expected_fname):
                    orig_expected_fname = os.path.join(baseline_dir, baseline) + '.pdf'
                expected_fname = make_test_filename(os.path.join(
                    result_dir, os.path.basename(orig_expected_fname)), 'expected')
                actual_fname = os.path.join(result_dir, baseline) + '.' + extension
                if os.path.exists(orig_expected_fname):
                    shutil.copyfile(orig_expected_fname, expected_fname)
                else:
                    will_fail = True
                    fail_msg = (
                        "Do not have baseline image {0} because this "
                        "file does not exist: {1}".format(
                            expected_fname,
                            orig_expected_fname
                        )
                    )

                @knownfailureif(
                    will_fail, fail_msg,
                    known_exception_class=ImageComparisonFailure)
                def do_test():
                    figure = plt.figure(fignum)

                    if self._remove_text:
                        self.remove_text(figure)

                    figure.savefig(actual_fname, **self._savefig_kwarg)

                    err = compare_images(expected_fname, actual_fname,
                                         self._tol, in_decorator=True)

                    try:
                        if not os.path.exists(expected_fname):
                            raise ImageComparisonFailure(
                                'image does not exist: %s' % expected_fname)

                        if err:
                            raise ImageComparisonFailure(
                                'images not close: %(actual)s vs. %(expected)s '
                                '(RMS %(rms).3f)'%err)
                    except ImageComparisonFailure:
                        if not check_freetype_version(self._freetype_version):
                            raise KnownFailureTest(
                                "Mismatched version of freetype.  Test requires '%s', you have '%s'" %
                                (self._freetype_version, ft2font.__freetype_version__))
                        raise

                yield (do_test,)
开发者ID:717524640,项目名称:matplotlib,代码行数:60,代码来源:decorators.py

示例3: mark_extension

    def mark_extension(extension):
        ''' Mark whether extension is supported. '''
        __tracebackhide__ = True  # pylint: disable=unused-variable

        if extension not in mplcmp.comparable_formats():
            raise unittest.SkipTest('Cannot compare {} files in this '
                                    'system'.format(extension))
开发者ID:gaomy3832,项目名称:easypyplot,代码行数:7,代码来源:__init__.py

示例4: _xfail_if_format_is_uncomparable

def _xfail_if_format_is_uncomparable(extension):
    will_fail = extension not in comparable_formats()
    if will_fail:
        fail_msg = 'Cannot compare %s files on this system' % extension
    else:
        fail_msg = 'No failure expected'

    return _knownfailureif(will_fail, fail_msg,
                           known_exception_class=ImageComparisonFailure)
开发者ID:mspacek,项目名称:matplotlib,代码行数:9,代码来源:decorators.py

示例5: test

    def test(self):
        baseline_dir, result_dir = _image_directories(self._func)

        for fignum, baseline in zip(plt.get_fignums(), self._baseline_images):
            figure = plt.figure(fignum)

            for extension in self._extensions:
                will_fail = not extension in comparable_formats()
                if will_fail:
                    fail_msg = 'Cannot compare %s files on this system' % extension
                else:
                    fail_msg = 'No failure expected'

                orig_expected_fname = os.path.join(baseline_dir, baseline) + '.' + extension
                if extension == 'eps' and not os.path.exists(orig_expected_fname):
                    orig_expected_fname = os.path.join(baseline_dir, baseline) + '.pdf'
                expected_fname = os.path.join(result_dir, 'expected-' + os.path.basename(orig_expected_fname))
                actual_fname = os.path.join(result_dir, baseline) + '.' + extension
                if os.path.exists(orig_expected_fname):
                    shutil.copyfile(orig_expected_fname, expected_fname)
                else:
                    will_fail = True
                    fail_msg = 'Do not have baseline image %s' % expected_fname

                @knownfailureif(
                    will_fail, fail_msg,
                    known_exception_class=ImageComparisonFailure)
                def do_test():
                    figure.savefig(actual_fname)

                    err = compare_images(expected_fname, actual_fname, self._tol, in_decorator=True)

                    if not os.path.exists(expected_fname):
                        raise ImageComparisonFailure(
                            'image does not exist: %s' % expected_fname)

                    if err:
                        raise ImageComparisonFailure(
                            'images not close: %(actual)s vs. %(expected)s '
                            '(RMS %(rms).3f)'%err)

                yield (do_test,)
开发者ID:AlexSzatmary,项目名称:matplotlib,代码行数:42,代码来源:decorators.py

示例6: _xfail_if_format_is_uncomparable

def _xfail_if_format_is_uncomparable(extension):
    import pytest
    return pytest.mark.xfail(
        extension not in comparable_formats(),
        reason='Cannot compare {} files on this system'.format(extension),
        raises=ImageComparisonFailure, strict=True)
开发者ID:DanHickstein,项目名称:matplotlib,代码行数:6,代码来源:decorators.py


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