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


Python VisualTest._get_html_row方法代码示例

本文整理汇总了Python中toolium.visual_test.VisualTest._get_html_row方法的典型用法代码示例。如果您正苦于以下问题:Python VisualTest._get_html_row方法的具体用法?Python VisualTest._get_html_row怎么用?Python VisualTest._get_html_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在toolium.visual_test.VisualTest的用法示例。


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

示例1: test_get_html_row

# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import _get_html_row [as 别名]
def test_get_html_row(driver_wrapper):
    expected_row = '<tr class=diff><td>report_name</td><td><img style="width: 100%" onclick=' \
                   '"launchModal\(this.src\)" src=".*register_v2.png"/></td></td><td><img style="width: 100%" ' \
                   'onclick="launchModal\(this.src\)" src=".*register.png"/></td></td><td></td></tr>'
    visual = VisualTest(driver_wrapper)
    row = visual._get_html_row('diff', 'report_name', file_v1, file_v2)
    assert re.compile(expected_row).match(row) is not None
开发者ID:Telefonica,项目名称:toolium,代码行数:9,代码来源:test_visual_test.py

示例2: test_get_html_row

# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import _get_html_row [as 别名]
def test_get_html_row(driver_wrapper):
    expected_row = '<tr class=diff><td>report_name</td><td><img src=".*register_v2.png" title="Baseline image"/>' \
                   '</td><td><img src=".*register.png" title="Screenshot image"/></td><td></td></tr>'
    visual = VisualTest(driver_wrapper)
    row = visual._get_html_row('diff', 'report_name', file_v1, file_v2)
    assert re.compile(expected_row).match(row) is not None
开发者ID:jframos,项目名称:toolium,代码行数:8,代码来源:test_visual_test.py

示例3: VisualTests

# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import _get_html_row [as 别名]

#.........这里部分代码省略.........
        self.visual = VisualTest(self.driver_wrapper)

        assert_is_instance(self.visual.engine, PilEngine)

    def test_compare_files_equals(self):
        message = self.visual.compare_files(self._testMethodName, self.file_v1, self.file_v1, 0)
        assert_is_none(message)

    def test_compare_files_diff(self):
        message = self.visual.compare_files(self._testMethodName, self.file_v1, self.file_v2, 0)
        assert_in('by a distance of 522.65', message)

    def test_compare_files_diff_fail(self):
        # Update conf and create a new VisualTest instance
        self.driver_wrapper.config.set('VisualTests', 'fail', 'true')
        self.visual = VisualTest(self.driver_wrapper)

        with assert_raises(AssertionError):
            self.visual.compare_files(self._testMethodName, self.file_v1, self.file_v2, 0)

    def test_compare_files_size(self):
        message = self.visual.compare_files(self._testMethodName, self.file_v1, self.file_small, 0)
        # PIL returns an empty error
        assert_equal('', message)

    def test_compare_files_size_fail(self):
        # Update conf and create a new VisualTest instance
        self.driver_wrapper.config.set('VisualTests', 'fail', 'true')
        self.visual = VisualTest(self.driver_wrapper)

        with assert_raises(AssertionError):
            self.visual.compare_files(self._testMethodName, self.file_v1, self.file_small, 0)

    def test_get_html_row(self):
        expected_row = '<tr class=diff><td>test_get_html_row</td><td><img style="width: 100%" onclick=' \
                       '"launchModal\(this.src\)" src=".*register_v2.png"/></td></td><td><img style="width: 100%" ' \
                       'onclick="launchModal\(this.src\)" src=".*register.png"/></td></td><td></td></tr>'
        row = self.visual._get_html_row('diff', self._testMethodName, self.file_v1, self.file_v2)
        assertRegex(self, row, expected_row)

    def assert_image(self, img, img_name, expected_image_filename):
        """Save img in an image file and compare with the expected image

        :param img: image object
        :param img_name: temporary filename
        :param expected_image_filename: filename of the expected image
        """
        # Save result image in output folder
        result_file = os.path.join(self.visual.output_directory, img_name + '.png')
        img.save(result_file)

        # Output image and expected image must be equals
        expected_image = os.path.join(self.root_path, 'resources', expected_image_filename + '.png')
        PilEngine().assertSameFiles(result_file, expected_image, 0.1)

    def test_crop_element(self):
        # Create element mock
        web_element = get_mock_element(x=250, y=40, height=40, width=300)

        # Resize image
        img = Image.open(self.file_v1)
        img = self.visual.crop_element(img, web_element)

        # Assert output image
        self.assert_image(img, self._testMethodName, 'register_cropped_element')
开发者ID:cesarca,项目名称:toolium,代码行数:69,代码来源:test_visual_test.py


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