Commit d6c5ad09 authored by Antonio Caceres's avatar Antonio Caceres
Browse files

Fix LHS/RHS error output and improve messaging.

parent 0661b185
No related merge requests found
Showing with 12 additions and 8 deletions
+12 -8
......@@ -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"
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.")
......@@ -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"
......@@ -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 + "'"
......@@ -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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment