本文整理汇总了Python中toolium.visual_test.VisualTest.compare_files方法的典型用法代码示例。如果您正苦于以下问题:Python VisualTest.compare_files方法的具体用法?Python VisualTest.compare_files怎么用?Python VisualTest.compare_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toolium.visual_test.VisualTest
的用法示例。
在下文中一共展示了VisualTest.compare_files方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_compare_files_size_fail
# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import compare_files [as 别名]
def test_compare_files_size_fail(driver_wrapper):
# Update conf and create a new VisualTest instance
driver_wrapper.config.set('VisualTests', 'fail', 'true')
visual = VisualTest(driver_wrapper)
with pytest.raises(AssertionError):
visual.compare_files('report_name', file_v1, file_small, 0)
示例2: test_compare_files_size
# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import compare_files [as 别名]
def test_compare_files_size(driver_wrapper):
visual = VisualTest(driver_wrapper)
message = visual.compare_files('report_name', file_v1, file_small, 0)
# PIL returns an empty error, but PyTest modifies AssertionError
assert 'assert (1680, 388) == (1246, 388)' in message
示例3: test_compare_files_diff
# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import compare_files [as 别名]
def test_compare_files_diff(driver_wrapper):
visual = VisualTest(driver_wrapper)
message = visual.compare_files('report_name', file_v1, file_v2, 0)
assert 'Distance of 0.00080181' in message
示例4: test_compare_files_equal
# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import compare_files [as 别名]
def test_compare_files_equal(driver_wrapper):
visual = VisualTest(driver_wrapper)
message = visual.compare_files('report_name', file_v1, file_v1, 0)
assert message is None
示例5: VisualTests
# 需要导入模块: from toolium.visual_test import VisualTest [as 别名]
# 或者: from toolium.visual_test.VisualTest import compare_files [as 别名]
class VisualTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Get file paths
cls.root_path = os.path.dirname(os.path.realpath(__file__))
cls.file_v1 = os.path.join(cls.root_path, 'resources', 'register.png')
cls.file_v2 = os.path.join(cls.root_path, 'resources', 'register_v2.png')
cls.file_small = os.path.join(cls.root_path, 'resources', 'register_small.png')
cls.file_ios = os.path.join(cls.root_path, 'resources', 'ios.png')
def setUp(self):
# Remove previous visual path
visual_path = os.path.join(self.root_path, 'output', 'visualtests')
if os.path.exists(visual_path):
shutil.rmtree(visual_path)
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
# Create a new wrapper
self.driver_wrapper = DriverWrappersPool.get_default_wrapper()
self.driver_wrapper.driver = mock.MagicMock()
# Configure properties
config_files = ConfigFiles()
config_files.set_config_directory(os.path.join(self.root_path, 'conf'))
config_files.set_config_properties_filenames('properties.cfg')
config_files.set_output_directory(os.path.join(self.root_path, 'output'))
self.driver_wrapper.configure(tc_config_files=config_files)
self.driver_wrapper.config.set('VisualTests', 'enabled', 'true')
# Create a new VisualTest instance
self.visual = VisualTest(self.driver_wrapper)
@classmethod
def tearDownClass(cls):
# Remove visual path
visual_path = os.path.join(cls.root_path, 'output', 'visualtests')
if os.path.exists(visual_path):
shutil.rmtree(visual_path)
# Reset wrappers pool values
DriverWrappersPool._empty_pool()
DriverWrapper.config_properties_filenames = None
def test_no_enabled(self):
# Update conf and create a new VisualTest instance
self.driver_wrapper.config.set('VisualTests', 'enabled', 'false')
self.visual = VisualTest(self.driver_wrapper)
self.visual.assert_screenshot(None, filename='screenshot_full', file_suffix='screenshot_suffix')
self.driver_wrapper.driver.save_screenshot.assert_not_called()
def test_engine_pil(self):
assert_is_instance(self.visual.engine, PilEngine)
def test_engine_perceptual(self):
# Update conf and create a new VisualTest instance
self.driver_wrapper.config.set('VisualTests', 'engine', 'perceptualdiff')
self.visual = VisualTest(self.driver_wrapper)
assert_is_instance(self.visual.engine, PerceptualEngine)
# def test_engine_magick(self):
# self.driver_wrapper.config.set('VisualTests', 'engine', 'imagemagick')
# visual = VisualTest()
# assert_is_instance(visual.engine, MagickEngine)
def test_engine_empty(self):
# Update conf and create a new VisualTest instance
self.driver_wrapper.config.set('VisualTests', 'engine', '')
self.visual = VisualTest(self.driver_wrapper)
assert_is_instance(self.visual.engine, PilEngine)
def test_engine_unknown(self):
# Update conf and create a new VisualTest instance
self.driver_wrapper.config.set('VisualTests', 'engine', 'unknown')
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):
#.........这里部分代码省略.........