Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test --mpl-kernel=phash
  • Loading branch information
bjlittle committed May 26, 2022
commit 2b48aff28c1f15432c67cd54eb8db2c99a627b5c
30 changes: 30 additions & 0 deletions tests/test_pytest_mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,33 @@ def test_results_always(tmpdir):
assert image and not image_exists
assert image not in html
assert json_res[json_image_key] is None


def test_phash(tmpdir, capsys):
test_file = tmpdir.join("test.py").strpath
with open(test_file, "w") as fo:
fo.write(TEST_GENERATE)

results_dir = tmpdir.mkdir("foo").strpath
gen_dir = tmpdir.mkdir("bar").strpath
hash_file = "test_phash.json"

code = call_pytest([f"--mpl-generate-path={gen_dir}", test_file])
assert code == 0
assert os.path.exists(os.path.join(gen_dir, "test_gen.png"))

command = [f"--mpl-generate-hash-library={hash_file}",
"--mpl-results-always",
f"--mpl-results-path={results_dir}",
"--mpl-kernel=phash",
test_file]
code = call_pytest(command)
hash_file = os.path.join(results_dir, hash_file)
assert os.path.exists(os.path.join(hash_file))

with open(hash_file) as fi:
hash_lib = json.load(fi)

with capsys.disabled():
from pprint import pprint
pprint(hash_lib)