No project description provided
Project description
pytest-image-diff
Installation
pip install pytest-image-diff
or from git
pip install -e git+https://githib.com/Apkawa/pytest-image-diff.git@master#egg=pytest-image-diff
Python>=3.6
Usage
from typing import Union
from PIL import Image
def test_compare(image_diff):
image: Image or str or bytes = Image.new()
image2: Image or str or bytes = '/path/to/image.jpeg'
image_diff(image, image2)
def test_regression(image_regression):
image: Union[Image, str, bytes] = Image.new()
image_regression(image, threshold=0.5)
First run creates reference images
pytest-splinter
Fixture screenshot_regression
enabled if pytest-splinter installed
import pytest
@pytest.fixture
def admin_browser(request, browser_instance_getter):
"""Admin browser fixture."""
# browser_instance_getter function receives parent fixture -- our admin_browser
return browser_instance_getter(request, admin_browser)
def test_2_browsers(browser, admin_browser, screenshot_regression):
"""Test using 2 browsers at the same time."""
browser.visit('http://google.com')
admin_browser.visit('http://admin.example.com')
screenshot_regression(suffix="browser")
screenshot_regression(admin_browser, suffix="admin browser")
def test_pytest_splinter(browser, screenshot_regression):
# Recommend fix window size for avoid regression
browser.driver.set_window_size(1280, 1024)
browser.visit('http://google.com')
screenshot_regression(suffix="main")
# ... some interaction
browser.click()
screenshot_regression(suffix="success")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pytest_image_diff-0.0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f48e2e4a0b48c75957219b7087d577a8fa7c9f0324458cf95a862195f29aaf1 |
|
MD5 | f9c123d7d691cb85659eed0586501cba |
|
BLAKE2b-256 | 5eca0849f46b268d2ace68c3451f93beefdb28e23aa140e0a24b4a5c5932036e |