diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-0.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-0.svg
new file mode 100644
index 00000000..72ebf366
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-0.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-1.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-1.svg
new file mode 100644
index 00000000..aa10a5ff
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-1.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-2.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-2.svg
new file mode 100644
index 00000000..5fc9ab24
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-2.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-3.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-3.svg
new file mode 100644
index 00000000..76f0129e
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-3.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-4.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-4.svg
new file mode 100644
index 00000000..2882a50e
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-4.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-5.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-5.svg
new file mode 100644
index 00000000..d390f299
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-5.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-6.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-6.svg
new file mode 100644
index 00000000..6043a87a
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-6.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-7.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-7.svg
new file mode 100644
index 00000000..04e5920f
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-7.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-8.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-8.svg
new file mode 100644
index 00000000..b5105950
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_for_loop/snapshot-8.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-0.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-0.svg
new file mode 100644
index 00000000..b0573526
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-0.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-1.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-1.svg
new file mode 100644
index 00000000..5c434546
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-1.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-2.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-2.svg
new file mode 100644
index 00000000..790deaf9
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-2.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-3.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-3.svg
new file mode 100644
index 00000000..09b73eb2
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-3.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-4.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-4.svg
new file mode 100644
index 00000000..844c2042
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_multi_line/snapshot-4.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-0.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-0.svg
new file mode 100644
index 00000000..74686a88
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-0.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-1.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-1.svg
new file mode 100644
index 00000000..899f18a1
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-1.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-2.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-2.svg
new file mode 100644
index 00000000..b86d9ff0
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_mutation/snapshot-2.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-0.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-0.svg
new file mode 100644
index 00000000..af4f1f13
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-0.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-1.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-1.svg
new file mode 100644
index 00000000..6e976d93
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_one_line/snapshot-1.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-0.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-0.svg
new file mode 100644
index 00000000..d361ecff
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-0.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-1.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-1.svg
new file mode 100644
index 00000000..f20565a5
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-1.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-2.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-2.svg
new file mode 100644
index 00000000..a888424d
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-2.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-3.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-3.svg
new file mode 100644
index 00000000..bfd556ae
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-3.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-4.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-4.svg
new file mode 100644
index 00000000..98f6d556
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-4.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-5.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-5.svg
new file mode 100644
index 00000000..4bc3be8b
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-5.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-6.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-6.svg
new file mode 100644
index 00000000..ad1fbe12
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-6.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-7.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-7.svg
new file mode 100644
index 00000000..0a6d8116
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-7.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-8.svg b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-8.svg
new file mode 100644
index 00000000..d3eda534
--- /dev/null
+++ b/tests/test_debug/snapshot_manager_testing_snapshots/func_while/snapshot-8.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/test_debug/test_snapshot_manager.py b/tests/test_debug/test_snapshot_manager.py
index 37098b98..f8e5431a 100644
--- a/tests/test_debug/test_snapshot_manager.py
+++ b/tests/test_debug/test_snapshot_manager.py
@@ -1,13 +1,15 @@
from __future__ import annotations
import os.path
-import shutil
import pytest
+from pytest_snapshot.plugin import Snapshot
from python_ta.debug import SnapshotManager
-SNAPSHOT_DIR = "snapshot_manager_testing_snapshots"
+SNAPSHOT_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), "snapshot_manager_testing_snapshots"
+)
TEST_RESULTS_DIR = "/tmp/test_results"
@@ -61,35 +63,27 @@ def func_while(output_path=None) -> SnapshotManager:
return manager
-def assert_output_files_match(snapshot_count: int, output_path: str, expected_path: str):
+def assert_output_files_match(
+ snapshot_count: int, output_path: str, snapshot: Snapshot, function_name: str
+):
+ actual_svgs = {}
for i in range(snapshot_count):
- actual_file = os.path.join(output_path, f"snapshot-{i}.svg")
- expected_file = os.path.join(expected_path, f"snapshot-{i}.svg")
- with open(actual_file) as actual_file, open(expected_file) as expected_file:
+ file_name = f"snapshot-{i}.svg"
+ actual_file = os.path.join(output_path, file_name)
+ with open(actual_file) as actual_file:
actual_svg = actual_file.read()
- expected_svg = expected_file.read()
- assert actual_svg == expected_svg
+ actual_svgs[file_name] = actual_svg
+ snapshot.assert_match_dir(actual_svgs, function_name)
@pytest.mark.parametrize(
"test_func", [func_one_line, func_multi_line, func_mutation, func_for_loop, func_while]
)
-# TODO: find a good way to take snapshots
-def test_snapshot_manger(test_func):
- # set up to ensure the output dir exists
- save_snapshots = False
-
+def test_snapshot_manger(test_func, snapshot):
+ snapshot.snapshot_dir = SNAPSHOT_DIR
actual_dir = os.path.join(TEST_RESULTS_DIR, test_func.__name__)
os.makedirs(actual_dir, exist_ok=True)
-
manager = test_func(actual_dir)
-
- expected_dir = os.path.join(SNAPSHOT_DIR, test_func.__name__)
- if save_snapshots:
- shutil.rmtree(expected_dir, ignore_errors=True)
- shutil.copytree(actual_dir, expected_dir, dirs_exist_ok=True)
- else:
- assert_output_files_match(manager.get_snapshot_count(), actual_dir, expected_dir)
-
- # clean up the test dir
- shutil.rmtree(actual_dir)
+ assert_output_files_match(
+ manager.get_snapshot_count(), actual_dir, snapshot, test_func.__name__
+ )