Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 4d73573

Browse files
committed
changed how dicts are updated in __state
1 parent 03ba91c commit 4d73573

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

src/clue/test/test_adafruit_clue.py

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ def test_acceleration(self):
7777
MOCK_MOTION_Z = 3
7878
MOCK_MOTION_X_B = 4
7979

80-
clue._Clue__state["acceleration"] = {
81-
"x": MOCK_MOTION_X_A,
82-
"y": MOCK_MOTION_Y,
83-
"z": MOCK_MOTION_Z,
84-
}
80+
clue._Clue__state["acceleration"].update(
81+
{"x": MOCK_MOTION_X_A, "y": MOCK_MOTION_Y, "z": MOCK_MOTION_Z,}
82+
)
8583
assert clue.acceleration == (MOCK_MOTION_X_A, MOCK_MOTION_Y, MOCK_MOTION_Z)
8684
clue._Clue__state["acceleration"]["x"] = MOCK_MOTION_X_B
8785
assert clue.acceleration == (MOCK_MOTION_X_B, MOCK_MOTION_Y, MOCK_MOTION_Z)
@@ -93,12 +91,14 @@ def test_color(self):
9391
MOCK_COLOR_C = 4
9492
MOCK_COLOR_R_B = 5
9593

96-
clue._Clue__state["color"] = {
97-
"r": MOCK_COLOR_R_A,
98-
"g": MOCK_COLOR_G,
99-
"b": MOCK_COLOR_B,
100-
"c": MOCK_COLOR_C,
101-
}
94+
clue._Clue__state["color"].update(
95+
{
96+
"r": MOCK_COLOR_R_A,
97+
"g": MOCK_COLOR_G,
98+
"b": MOCK_COLOR_B,
99+
"c": MOCK_COLOR_C,
100+
}
101+
)
102102
assert clue.color == (MOCK_COLOR_R_A, MOCK_COLOR_G, MOCK_COLOR_B, MOCK_COLOR_C)
103103
assert clue._Clue__state["color"]["r"] == MOCK_COLOR_R_B
104104
assert clue.color == (MOCK_COLOR_R_B, MOCK_COLOR_G, MOCK_COLOR_B, MOCK_COLOR_C)
@@ -117,11 +117,9 @@ def test_magnetic(self):
117117
MOCK_MAGNETIC_Z = 3
118118
MOCK_MAGNETIC_X_B = 4
119119

120-
clue._Clue__state["magnetometer"] = {
121-
"x": MOCK_MAGNETIC_X_A,
122-
"y": MOCK_MAGNETIC_Y,
123-
"z": MOCK_MAGNETIC_Z,
124-
}
120+
clue._Clue__state["magnetometer"].update(
121+
{"x": MOCK_MAGNETIC_X_A, "y": MOCK_MAGNETIC_Y, "z": MOCK_MAGNETIC_Z,}
122+
)
125123
assert clue.acceleration == (
126124
MOCK_MAGNETIC_X_A,
127125
MOCK_MAGNETIC_Y,
@@ -148,11 +146,9 @@ def test_gyro(self):
148146
MOCK_GYRO_Z = 3
149147
MOCK_GYRO_X_B = 4
150148

151-
clue._Clue__state["gyro"] = {
152-
"x": MOCK_GYRO_X_A,
153-
"y": MOCK_GYRO_Y,
154-
"z": MOCK_GYRO_Z,
155-
}
149+
clue._Clue__state["gyro"].update(
150+
{"x": MOCK_GYRO_X_A, "y": MOCK_GYRO_Y, "z": MOCK_GYRO_Z,}
151+
)
156152
assert clue.gyro == (MOCK_GYRO_X_A, MOCK_GYRO_Y, MOCK_GYRO_Z)
157153
clue._Clue__state["gyro"]["x"] = MOCK_GYRO_X_B
158154
assert clue.gyro == (MOCK_GYRO_X_B, MOCK_GYRO_Y, MOCK_GYRO_Z)
@@ -184,8 +180,8 @@ def test_pressure(self):
184180
def test_altitude(self):
185181
MOCK_PRESSURE_A = 1000
186182
MOCK_PRESSURE_B = 1030
187-
MOCK_ALTITUDE_A = 125.42
188-
MOCK_ALTITUDE_B = -123.93
183+
MOCK_ALTITUDE_A = 125.42255615546036
184+
MOCK_ALTITUDE_B = -123.93061640175468
189185
SEA_LEVEL_PRESSURE = 1015
190186
clue.sea_level_pressure = SEA_LEVEL_PRESSURE
191187
clue._Clue__state["pressure"] = MOCK_PRESSURE_A
@@ -202,6 +198,6 @@ def test_pixel(self):
202198
MOCK_RED = (255, 0, 0)
203199
MOCK_WHITE = (255, 255, 255)
204200
clue.pixel.fill(MOCK_RED)
205-
assert MOCK_RED == clue.pixel
201+
assert [MOCK_RED] == clue.pixel
206202
clue.pixel.fill(MOCK_WHITE)
207-
assert MOCK_WHITE == clue.pixel
203+
assert [MOCK_WHITE] == clue.pixel

0 commit comments

Comments
 (0)