Skip to content

Commit 2b48aff

Browse files
committed
test --mpl-kernel=phash
1 parent b69d734 commit 2b48aff

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_pytest_mpl.py

+30
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,33 @@ def test_results_always(tmpdir):
489489
assert image and not image_exists
490490
assert image not in html
491491
assert json_res[json_image_key] is None
492+
493+
494+
def test_phash(tmpdir, capsys):
495+
test_file = tmpdir.join("test.py").strpath
496+
with open(test_file, "w") as fo:
497+
fo.write(TEST_GENERATE)
498+
499+
results_dir = tmpdir.mkdir("foo").strpath
500+
gen_dir = tmpdir.mkdir("bar").strpath
501+
hash_file = "test_phash.json"
502+
503+
code = call_pytest([f"--mpl-generate-path={gen_dir}", test_file])
504+
assert code == 0
505+
assert os.path.exists(os.path.join(gen_dir, "test_gen.png"))
506+
507+
command = [f"--mpl-generate-hash-library={hash_file}",
508+
"--mpl-results-always",
509+
f"--mpl-results-path={results_dir}",
510+
"--mpl-kernel=phash",
511+
test_file]
512+
code = call_pytest(command)
513+
hash_file = os.path.join(results_dir, hash_file)
514+
assert os.path.exists(os.path.join(hash_file))
515+
516+
with open(hash_file) as fi:
517+
hash_lib = json.load(fi)
518+
519+
with capsys.disabled():
520+
from pprint import pprint
521+
pprint(hash_lib)

0 commit comments

Comments
 (0)