Repository: tophat/syrupy

Issue:
Hide snapshot report summary if there is nothing to report
**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

No point in outputting a summary when there is nothing to report

**Describe the solution you'd like**

<!-- A clear and concise description of what you want to happen. -->

Patched this myself by modifying the `pytest_terminal_summary` hook to the following,
will happily make a PR if this is wanted.

```py
with __terminal_color(config):
    lines = terminalreporter.config._syrupy.report.lines
    first = next(lines)
    if first:
        terminalreporter.write_sep("-", gettext("snapshot report summary"))
        terminalreporter.write_line(first)
        for line in lines:
            terminalreporter.write_line(line)
```

**Describe alternatives you've considered**

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**

<!-- Add any other context or screenshots about the feature request here. -->


Discussion:

Patch:
diff --git a/src/syrupy/__init__.py b/src/syrupy/__init__.py
index 560ddb0..1793b67 100644
--- a/src/syrupy/__init__.py
+++ b/src/syrupy/__init__.py
@@ -173,9 +173,14 @@ def pytest_terminal_summary(
     https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_terminal_summary
     """
     with __terminal_color(config):
-        terminalreporter.write_sep("-", gettext("snapshot report summary"))
+        is_printing_report = False
         for line in terminalreporter.config._syrupy.report.lines:
-            terminalreporter.write_line(line)
+            has_report_line = bool(line.strip())
+            if has_report_line and not is_printing_report:
+                terminalreporter.write_sep("-", gettext("snapshot report summary"))
+                is_printing_report = True
+            if is_printing_report:
+                terminalreporter.write_line(line)
 
 
 @pytest.fixture


Test patch:
diff --git a/tests/integration/test_pytest_extension.py b/tests/integration/test_pytest_extension.py
index 1fd1a9a..2c34efe 100644
--- a/tests/integration/test_pytest_extension.py
+++ b/tests/integration/test_pytest_extension.py
@@ -35,3 +35,28 @@ def test_handles_pyargs_non_module_when_both_given(testdir):
         "-v", "test_file.py", "--pyargs", "test_file", "--snapshot-update"
     )
     assert result.ret == 0
+
+
+def test_does_not_print_empty_snapshot_report(testdir):
+    testdir.makeconftest("")
+    testcase_no_snapshots = """
+        def test_example(snapshot):
+            assert 1
+        """
+    testcase_yes_snapshots = """
+        def test_example(snapshot):
+            assert snapshot == 1
+        """
+    testdir.makepyfile(
+        test_file_no=testcase_no_snapshots, test_file_yes=testcase_yes_snapshots
+    )
+
+    result = testdir.runpytest("-v", "test_file_no.py", "--snapshot-update")
+    result.stdout.re_match_lines((r".*test_file_no.py.*"))
+    assert "snapshot report" not in result.stdout.str()
+    assert "test_file_yes" not in result.stdout.str()
+    assert result.ret == 0
+
+    result = testdir.runpytest("-v", "test_file_yes.py", "--snapshot-update")
+    result.stdout.re_match_lines((r".*test_file_yes.py.*", r".*snapshot report.*"))
+    assert result.ret == 0