Skip to content

Commit 49fcd8d

Browse files
committed
Generate baseline with full path for tox
1 parent 2796fad commit 49fcd8d

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

tests/subtests/subtest.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,24 @@ def test_hdiff_imatch_savefig():
8484
return plot([1, 2, 3, 4])
8585

8686

87-
# Different baseline directory
88-
# TODO: Test with a remote `baseline_dir`
89-
@pytest.mark.mpl_image_compare(baseline_dir='baseline/other')
90-
def test_hdiff_imatch_baselinedir():
91-
return plot([4, 2, 1, 4])
92-
93-
94-
# Different filename
95-
@pytest.mark.mpl_image_compare(filename='test_hdiff_imatch_filename_other.png')
96-
def test_hdiff_imatch_filename():
97-
return plot([4, 2, 1, 4])
98-
99-
100-
# Different hash library
101-
@pytest.mark.mpl_image_compare(hash_library='hashes/other/other.json')
102-
def test_hdiff_imatch_filename():
103-
return plot([4, 2, 1, 4])
87+
# TODO: Implement these path altering tests later
88+
# # Different baseline directory
89+
# # TODO: Test with a remote `baseline_dir`
90+
# @pytest.mark.mpl_image_compare(baseline_dir='baseline/other')
91+
# def test_hdiff_imatch_baselinedir():
92+
# return plot([4, 2, 1, 4])
93+
#
94+
#
95+
# # Different filename
96+
# @pytest.mark.mpl_image_compare(filename='test_hdiff_imatch_filename_other.png')
97+
# def test_hdiff_imatch_filename():
98+
# return plot([4, 2, 1, 4])
99+
#
100+
#
101+
# # Different hash library
102+
# @pytest.mark.mpl_image_compare(hash_library='hashes/other/other.json')
103+
# def test_hdiff_imatch_hashlibrary():
104+
# return plot([4, 2, 1, 4])
104105

105106

106107
# Different style

tests/subtests/test_subtest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
HASH_LIBRARY = Path(__file__).parent / 'hashes' / (VERSION_ID + ".json")
1818
RESULT_LIBRARY = Path(__file__).parent / 'result_hashes' / (VERSION_ID + ".json")
1919
HASH_LIBRARY_FLAG = rf'--mpl-hash-library={HASH_LIBRARY}'
20+
FULL_BASELINE_PATH = Path(__file__).parent / 'baseline'
2021

2122
BASELINE_IMAGES_FLAG = '--mpl-baseline-path=baseline'
2223

@@ -62,7 +63,7 @@ def run_subtest(baseline_summary_name, tmp_path, args, summaries=None, xfail=Tru
6263
mpl_args = ['--mpl', rf'--mpl-results-path={results_path.as_posix()}',
6364
f'--mpl-generate-summary={summaries}']
6465
if update_baseline:
65-
mpl_args += ['--mpl-generate-path=baseline']
66+
mpl_args += [rf'--mpl-generate-path={FULL_BASELINE_PATH}']
6667
if HASH_LIBRARY.exists():
6768
mpl_args += [rf'--mpl-generate-hash-library={HASH_LIBRARY}']
6869

@@ -72,6 +73,9 @@ def run_subtest(baseline_summary_name, tmp_path, args, summaries=None, xfail=Tru
7273
# If updating baseline, don't check summaries
7374
if update_baseline:
7475
assert status == 0
76+
if HASH_LIBRARY.exists():
77+
# Keep in sync. Use `git add -p` to commit specific lines.
78+
shutil.copy(HASH_LIBRARY, RESULT_LIBRARY)
7579
return
7680

7781
# Ensure exit status is as expected

0 commit comments

Comments
 (0)