Skip to content

Commit 66a9f55

Browse files
committed
Docs
1 parent b8008b8 commit 66a9f55

File tree

11 files changed

+593
-69
lines changed

11 files changed

+593
-69
lines changed

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![PyPi](https://img.shields.io/pypi/v/pytest-image-diff.svg)](https://pypi.python.org/pypi/pytest-image-diff)
2-
[![Build Status](https://travis-ci.org/Apkawa/pytest-image-diff.svg?branch=master)](https://travis-ci.org/Apkawa/pytest-image-diff)
3-
[![Documentation Status](https://readthedocs.org/projects/pytest-image-diff/badge/?version=latest)](https://pytest-ngrok.readthedocs.io/en/latest/?badge=latest)
2+
[![ci](https://github.com/Apkawa/pytest-image-diff/actions/workflows/ci.yml/badge.svg)](https://github.com/Apkawa/pytest-image-diff/actions/workflows/ci.yml)
3+
[![Documentation Status](https://readthedocs.org/projects/pytest-image-diff/badge/?version=latest)](https://pytest-image-diff.readthedocs.io/en/latest/?badge=latest)
44
[![Codecov](https://codecov.io/gh/Apkawa/pytest-image-diff/branch/master/graph/badge.svg)](https://codecov.io/gh/Apkawa/pytest-image-diff)
55
[![Requirements Status](https://requires.io/github/Apkawa/pytest-image-diff/requirements.svg?branch=master)](https://requires.io/github/Apkawa/pytest-image-diff/requirements/?branch=master)
66
[![PyUP](https://pyup.io/repos/github/Apkawa/pytest-image-diff/shield.svg)](https://pyup.io/repos/github/Apkawa/pytest-image-diff)
@@ -21,12 +21,13 @@ or from git
2121
pip install -e git+https://githib.com/Apkawa/pytest-image-diff.git@master#egg=pytest-image-diff
2222
```
2323

24-
Python>=3.5
24+
Python>=3.6
2525

2626

2727
# Usage
2828

2929
```python
30+
from typing import Union
3031
from PIL import Image
3132

3233

@@ -35,7 +36,43 @@ def test_compare(image_diff):
3536
image2: Image or str or bytes = '/path/to/image.jpeg'
3637
image_diff(image, image2)
3738

39+
3840
def test_regression(image_regression):
39-
image: Image or str or bytes = Image.new()
40-
image_regression(image)
41+
image: Union[Image, str, bytes] = Image.new()
42+
image_regression(image, threshold=0.5)
43+
```
44+
45+
First run creates reference images
46+
47+
## pytest-splinter
48+
49+
Fixture `screenshot_regression` enabled if pytest-splinter installed
50+
51+
```python3
52+
import pytest
53+
54+
@pytest.fixture
55+
def admin_browser(request, browser_instance_getter):
56+
"""Admin browser fixture."""
57+
# browser_instance_getter function receives parent fixture -- our admin_browser
58+
return browser_instance_getter(request, admin_browser)
59+
60+
def test_2_browsers(browser, admin_browser, screenshot_regression):
61+
"""Test using 2 browsers at the same time."""
62+
browser.visit('http://google.com')
63+
admin_browser.visit('http://admin.example.com')
64+
65+
screenshot_regression(suffix="browser")
66+
screenshot_regression(admin_browser, suffix="admin browser")
67+
68+
def test_pytest_splinter(browser, screenshot_regression):
69+
# Recommend fix window size for avoid regression
70+
browser.driver.set_window_size(1280, 1024)
71+
72+
browser.visit('http://google.com')
73+
74+
screenshot_regression(suffix="main")
75+
# ... some interaction
76+
browser.click()
77+
screenshot_regression(suffix="success")
4178
```

docs/source/code.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
API Reference
2+
=============
3+
4+
Config fixtures
5+
---------------
6+
7+
.. autofunction:: pytest_image_diff.plugin.image_diff_threshold
8+
9+
.. autofunction:: pytest_image_diff.plugin.image_diff_root
10+
.. autofunction:: pytest_image_diff.plugin.image_diff_dir
11+
.. autofunction:: pytest_image_diff.plugin.image_diff_reference_dir
12+
13+
14+
Fixtures
15+
--------
16+
17+
.. autofunction:: pytest_image_diff.plugin.image_regression
18+
19+
.. autofunction:: pytest_image_diff.plugin.image_diff
20+
21+
22+
pytest-splinter helper
23+
----------------------
24+
25+
.. autofunction:: pytest_image_diff.plugin.screenshot_regression

docs/source/conf.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,23 @@
1212
# add these directories to sys.path here. If the directory is relative to the
1313
# documentation root, use os.path.abspath to make it absolute, like shown here.
1414
#
15-
# import os
16-
# import sys
17-
# sys.path.insert(0, os.path.abspath('.'))
15+
import os
16+
import sys
17+
18+
sys.path.insert(0, os.path.abspath("../.."))
1819

1920

2021
# -- Project information -----------------------------------------------------
2122

2223

2324
project = "pytest-image-diff"
24-
copyright = "2020, Apkawa <[email protected]"
25+
copyright = "2016, Apkawa <[email protected]"
2526
author = "Apkawa <[email protected]"
2627

2728
# The short X.Y version
28-
version = "0.0"
29+
version = "0.4"
2930
# The full version, including alpha/beta/rc tags
30-
release = "0.0.5"
31+
release = "0.4.0"
3132

3233
# -- General configuration ---------------------------------------------------
3334

@@ -38,11 +39,24 @@
3839
# Add any Sphinx extension module names here, as strings. They can be
3940
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4041
# ones.
41-
extensions = ["m2r"]
42+
extensions = [
43+
"sphinx.ext.todo",
44+
"sphinx.ext.viewcode",
45+
"sphinx.ext.autodoc",
46+
"sphinx_autodoc_typehints",
47+
"sphinx_paramlinks",
48+
"m2r2",
49+
]
50+
51+
autodoc_member_order = "bysource"
4252

4353
# Add any paths that contain templates here, relative to this directory.
4454
templates_path = ["_templates"]
4555

56+
from recommonmark.parser import CommonMarkParser
57+
58+
source_parsers = {".md": CommonMarkParser}
59+
4660
source_suffix = [".rst", ".md"]
4761

4862
# The master toctree document.
@@ -63,12 +77,12 @@
6377
# The name of the Pygments (syntax highlighting) style to use.
6478
pygments_style = "sphinx"
6579

80+
6681
# -- Options for HTML output -------------------------------------------------
6782

6883
# The theme to use for HTML and HTML Help pages. See the documentation for
6984
# a list of builtin themes.
7085
#
71-
# html_theme = 'alabaster'
7286
html_theme = "sphinx_rtd_theme"
7387

7488
# Theme options are theme-specific and customize the look and feel of a theme
@@ -96,7 +110,7 @@
96110
# -- Options for HTMLHelp output ---------------------------------------------
97111

98112
# Output file base name for HTML help builder.
99-
htmlhelp_basename = " pytest-image-diffdoc"
113+
htmlhelp_basename = project + "doc"
100114

101115
# -- Options for LaTeX output ------------------------------------------------
102116

@@ -119,22 +133,14 @@
119133
# (source start file, target name, title,
120134
# author, documentclass [howto, manual, or own class]).
121135
latex_documents = [
122-
(
123-
master_doc,
124-
" pytest-image-diff.tex",
125-
" pytest-image-diff Documentation",
126-
"Apkawa",
127-
"manual",
128-
)
136+
(master_doc, project + ".tex", project + " Documentation", "Apkawa", "manual")
129137
]
130138

131139
# -- Options for manual page output ------------------------------------------
132140

133141
# One entry per manual page. List of tuples
134142
# (source start file, name, description, authors, manual section).
135-
man_pages = [
136-
(master_doc, " pytest-image-diff", " pytest-image-diff Documentation", [author], 1)
137-
]
143+
man_pages = [(master_doc, project, project + " Documentation", [author], 1)]
138144

139145
# -- Options for Texinfo output ----------------------------------------------
140146

@@ -144,10 +150,10 @@
144150
texinfo_documents = [
145151
(
146152
master_doc,
147-
" pytest-image-diff",
148-
" pytest-image-diff Documentation",
153+
project,
154+
project + " Documentation",
149155
author,
150-
"pytest-image-diff",
156+
project,
151157
"One line description of project.",
152158
"Miscellaneous",
153159
)
@@ -158,7 +164,7 @@
158164

159165
# At the bottom of conf.py
160166
def setup(app):
161-
git_doc_root = "https://githib.com/Apkawa/%3Cspan%20class="x x-first x-last">pytest-image-diff/blob/master/docs/"
167+
git_doc_root = "https://githib.com/Apkawa/%3Cspan%20class="x x-first x-last">%s/blob/master/docs/" % project
162168
app.add_config_value(
163169
"recommonmark_config",
164170
{

docs/source/contributing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Contributors
2+
============
3+
4+
.. mdinclude:: ../../CONTRIBUTING.md

docs/source/index.rst

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
pytest-image-diff documentation!
2-
====================================
3-
4-
|PyPi|
5-
|Build Status|
6-
|Documentation Status|
7-
|Codecov|
8-
|Requirements Status|
9-
|PyUP|
10-
|PyPi Python versions|
11-
|License|
1+
.. mdinclude:: ../../README.md
122

133
.. toctree::
14-
:maxdepth: 3
15-
:caption:
16-
readme
4+
:maxdepth: 1
5+
:caption: Contents
6+
7+
code
8+
contributing
179

1810

1911
Indices and tables
@@ -22,22 +14,3 @@ Indices and tables
2214
* :ref:`genindex`
2315
* :ref:`modindex`
2416
* :ref:`search`
25-
26-
27-
28-
.. |PyPi| image:: https://img.shields.io/pypi/v/pytest-image-diff.svg
29-
:target: https://pypi.python.org/pypi/pytest-image-diff
30-
.. |Build Status| image:: https://travis-ci.org/Apkawa/pytest-image-diff.svg?branch=master
31-
:target: https://travis-ci.org/Apkawa/pytest-image-diff
32-
.. |Documentation Status| image:: https://readthedocs.org/projects/pytest-image-diff/badge/?version=latest
33-
:target: https://pytest-ngrok.readthedocs.io/en/latest/?badge=latest
34-
.. |Codecov| image:: https://codecov.io/gh/Apkawa/pytest-image-diff/branch/master/graph/badge.svg
35-
:target: https://codecov.io/gh/Apkawa/pytest-image-diff
36-
.. |Requirements Status| image:: https://requires.io/github/Apkawa/pytest-image-diff/requirements.svg?branch=master
37-
:target: https://requires.io/github/Apkawa/pytest-image-diff/requirements/?branch=master
38-
.. |PyUP| image:: https://pyup.io/repos/github/Apkawa/pytest-image-diff/shield.svg
39-
:target: https://pyup.io/repos/github/Apkawa/pytest-image-diff
40-
.. |PyPi Python versions| image:: https://img.shields.io/pypi/pyversions/pytest-image-diff.svg
41-
:target: https://pypi.python.org/pypi/pytest-image-diff
42-
.. |License| image:: https://img.shields.io/badge/license-MIT-blue.svg
43-
:target: LICENSE

docs/source/readme.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

pytest_image_diff/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def image_diff_root(request: FixtureRequest) -> str:
4848
@pytest.fixture(scope="session") # pragma: no cover
4949
def image_diff_dir(image_diff_root: str) -> str:
5050
"""
51-
Path for store diff images. by default - '.tests/image_diff/'
51+
Path for store diff images. by default - '{image_diff_root}.tests/image_diff/'
5252
"""
5353
return os.path.join(image_diff_root, ".tests/image_diff/")
5454

@@ -112,6 +112,7 @@ def image_regression(
112112
) -> Generator[ImageRegressionCallableType, None, None]:
113113
"""
114114
Check regression image.
115+
115116
:param image: `PIL.Image` or `PathLike` or `io.BinaryIO`
116117
:param threshold: float, by default from `image_diff_threshold`
117118
:param suffix: str, need for multiple checks by one test
@@ -163,6 +164,7 @@ def image_diff(
163164
) -> Generator[ImageDiffCallableType, None, None]:
164165
"""
165166
Compare two image
167+
166168
:param image: `PIL.Image` or `PathLike` or `io.BinaryIO`
167169
:param image2: `PIL.Image` or `PathLike` or `io.BinaryIO`
168170
:param threshold: float, by default from `image_diff_threshold`

requirements-dev.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ mock==3.0.5
1212

1313
# Docs
1414

15-
Sphinx
15+
Sphinx>=4.0
1616
#alabaster
17-
sphinx_rtd_theme
18-
recommonmark
19-
m2r
17+
sphinx_rtd_theme>=0.5.2
18+
recommonmark>=0.7.1
19+
m2r2
20+
sphinx-autodoc-typehints
21+
sphinx-paramlinks
2022

2123
# QA
2224
pre-commit==2.13.0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ def read(fname):
6969
"License :: OSI Approved :: MIT License",
7070
"Programming Language :: Python",
7171
"Programming Language :: Python :: 3",
72-
"Programming Language :: Python :: 3.5",
7372
"Programming Language :: Python :: 3.6",
7473
"Programming Language :: Python :: 3.7",
7574
"Programming Language :: Python :: 3.8",
75+
"Programming Language :: Python :: 3.9",
76+
"Programming Language :: Python :: 3.10",
7677
],
7778
)

0 commit comments

Comments
 (0)