From d6c5ad099c820ea2ee17b7b0b2bbd8b45cca0bbb Mon Sep 17 00:00:00 2001
From: Antonio Caceres <antonio@antonio-caceres.com>
Date: Fri, 11 Oct 2024 16:12:28 -0700
Subject: [PATCH] Fix LHS/RHS error output and improve messaging.

---
 tests/0.D/test_pulse.py             | 4 ++--
 tests/0.D/test_translate_message.py | 8 ++++++--
 tests/1.C/test_prox_pulse.py        | 4 ++--
 tests/2.A/test_add_mark.py          | 2 +-
 tests/2.A/test_set_color.py         | 2 +-
 5 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/tests/0.D/test_pulse.py b/tests/0.D/test_pulse.py
index 5e2207e..47f4f1c 100644
--- a/tests/0.D/test_pulse.py
+++ b/tests/0.D/test_pulse.py
@@ -19,8 +19,8 @@ def test_pulse(set_color, time):
     pixel = Pixel(time)
     src.pulse.pulse(pixel, set_color, time)
     color, hist = pixel.look()
-    assert hist == [
+    assert [
         ((0, 0, 0), 0),
         (set_color, 1),
         ((0, 0, 0), 2),
-    ], "the pulse function should change color, wait, change color again, and wait again"
+    ] == hist, "the pulse function should change color, wait, change color again, and wait again"
diff --git a/tests/0.D/test_translate_message.py b/tests/0.D/test_translate_message.py
index d6840d2..ac996f6 100644
--- a/tests/0.D/test_translate_message.py
+++ b/tests/0.D/test_translate_message.py
@@ -1,6 +1,7 @@
 import pytest
 import os
 from src.morse_code import translate_message
+from src.symbols import InvalidSymbolError
 from tests.helpers.translate_message_data import WHOLE_MESSAGE_TESTS
 
 from tests.helpers.naming import apply_names
@@ -11,5 +12,8 @@ from tests.helpers.naming import apply_names
     apply_names("translate_message", [True, False], WHOLE_MESSAGE_TESTS),
 )
 def test_decode_message(msg, expected):
-    result = translate_message(msg)
-    assert result == expected
+    try:
+        result = translate_message(msg)
+        assert expected == result
+    except InvalidSymbolError:
+        pytest.fail("translate_message should catch any InvalidSymbolError.")
diff --git a/tests/1.C/test_prox_pulse.py b/tests/1.C/test_prox_pulse.py
index d675794..95c3c5c 100644
--- a/tests/1.C/test_prox_pulse.py
+++ b/tests/1.C/test_prox_pulse.py
@@ -16,8 +16,8 @@ def test_prox_pulse(prox_val, set_color, duration):
     pixel = Pixel(duration)
     src.prox_pulse.prox_pulse(pixel, set_color, prox_val)
     color, hist = pixel.look()
-    assert hist == [
+    assert [
         ((0, 0, 0), 0),
         (set_color, 1),
         ((0, 0, 0), 2),
-    ], "the prox_pulse function should have pulsed the provided color"
+    ] == hist, "the prox_pulse function should have pulsed the provided color"
diff --git a/tests/2.A/test_add_mark.py b/tests/2.A/test_add_mark.py
index b2186ec..d2e77a2 100644
--- a/tests/2.A/test_add_mark.py
+++ b/tests/2.A/test_add_mark.py
@@ -7,5 +7,5 @@ from tests.helpers.naming import apply_names
 @pytest.mark.parametrize("interval, expected", apply_names('add_mark', [True, False], ADD_MARK_DATA))
 def test_add_mark(interval, expected):
     mark = add_mark(interval)
-    assert mark == expected, "add_mark should have added the mark '" + \
+    assert expected == mark, "add_mark should have added the mark '" + \
         str(expected) + "', but you added '" + mark + "'"
diff --git a/tests/2.A/test_set_color.py b/tests/2.A/test_set_color.py
index e61708e..8a2488b 100644
--- a/tests/2.A/test_set_color.py
+++ b/tests/2.A/test_set_color.py
@@ -10,5 +10,5 @@ def test_set_color(interval, expected):
     pixel = Pixel(-1)
     set_color(interval, pixel)
     color, hist = pixel.look()
-    assert color == expected, "set_color should have changed the color to " + \
+    assert expected == color, "set_color should have changed the color to " + \
         str(expected) + ", but you changed it to " + str(color)
-- 
GitLab