Skip to content

Commit 727910c

Browse files
committed
working phash lib
1 parent 2b48aff commit 727910c

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

tests/baseline/hashes/test_phash.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"test.test_gen": "8fe8c01f7a05b01f6645ac1fe95f0b2a807e2ae2d41a7ab085967aac87997eab",
3+
"pytest-mpl-kernel": "phash"
4+
}

tests/test_pytest_mpl.py

+5-21
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
fail_hash_library = Path(__file__).parent / "baseline" / "test_hash_lib.json"
3333
baseline_dir_abs = Path(__file__).parent / "baseline" / baseline_subdir
3434
hash_baseline_dir_abs = Path(__file__).parent / "baseline" / "hybrid"
35+
phash_library = Path(__file__).parent / "baseline" / "hashes" / "test_phash.json"
3536

3637

3738
WIN = sys.platform.startswith('win')
@@ -491,31 +492,14 @@ def test_results_always(tmpdir):
491492
assert json_res[json_image_key] is None
492493

493494

494-
def test_phash(tmpdir, capsys):
495+
def test_phash(tmpdir):
495496
test_file = tmpdir.join("test.py").strpath
496497
with open(test_file, "w") as fo:
497498
fo.write(TEST_GENERATE)
498499

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}",
500+
command = ["--mpl",
510501
"--mpl-kernel=phash",
502+
f"--mpl-hash-library={phash_library}",
511503
test_file]
512504
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)
505+
assert code == 0

0 commit comments

Comments
 (0)