Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-24fa
project03
Commits
d6c5ad09
Commit
d6c5ad09
authored
6 months ago
by
Antonio Caceres
Browse files
Options
Download
Email Patches
Plain Diff
Fix LHS/RHS error output and improve messaging.
parent
0661b185
master
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
tests/0.D/test_pulse.py
+2
-2
tests/0.D/test_pulse.py
tests/0.D/test_translate_message.py
+6
-2
tests/0.D/test_translate_message.py
tests/1.C/test_prox_pulse.py
+2
-2
tests/1.C/test_prox_pulse.py
tests/2.A/test_add_mark.py
+1
-1
tests/2.A/test_add_mark.py
tests/2.A/test_set_color.py
+1
-1
tests/2.A/test_set_color.py
with
12 additions
and
8 deletions
+12
-8
tests/0.D/test_pulse.py
View file @
d6c5ad09
...
...
@@ -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"
This diff is collapsed.
Click to expand it.
tests/0.D/test_translate_message.py
View file @
d6c5ad09
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."
)
This diff is collapsed.
Click to expand it.
tests/1.C/test_prox_pulse.py
View file @
d6c5ad09
...
...
@@ -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"
This diff is collapsed.
Click to expand it.
tests/2.A/test_add_mark.py
View file @
d6c5ad09
...
...
@@ -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
+
"'"
This diff is collapsed.
Click to expand it.
tests/2.A/test_set_color.py
View file @
d6c5ad09
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help