Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit d2cd614

Browse files
committed
make tests more robust against little timing issues
1 parent 1aa8b98 commit d2cd614

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

runestone/activecode/test/test_activecode.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_hello(self):
3030
rb = t1.find_element_by_class_name("run-button")
3131
self.assertIsNotNone(rb)
3232
rb.click()
33+
time.sleep(0.5)
3334
output = t1.find_element_by_class_name("ac_output")
3435
self.assertEqual(output.text.strip(), "Hello World")
3536

@@ -53,6 +54,7 @@ def test_hidden(self):
5354
rb = t1.find_element_by_class_name("run-button")
5455
self.assertIsNotNone(rb)
5556
rb.click()
57+
time.sleep(0.5)
5658
output = t1.find_element_by_class_name("ac_output")
5759
self.assertIn("My Code", output.text.strip())
5860
self.assertIn("hidden code", output.text.strip())
@@ -171,6 +173,7 @@ def test_sql_activecode(self):
171173
rb = t2.find_element_by_class_name("run-button")
172174
self.assertIsNotNone(rb)
173175
rb.click()
176+
time.sleep(0.5)
174177
res = self.driver.find_element_by_id("sql1_sql_out")
175178
self.assertIsNotNone(res)
176179
out = self.driver.find_element_by_id("sql1_stdout")
@@ -205,8 +208,9 @@ def test_altair(self):
205208
rb.click()
206209
out = t2.find_element_by_id("alt_kiva_bar1_stdout")
207210
self.assertIsNotNone(out)
208-
self.assertTrue("mark = bar" in out.text)
209-
self.assertTrue("{'field': 'customer', 'type': 'nominal'}" in out.text)
211+
time.sleep(.5)
212+
self.assertIn("mark = bar", out.text)
213+
self.assertIn("{'field': 'customer', 'type': 'nominal'}", out.text)
210214
can = t2.find_element_by_tag_name("canvas")
211215
self.assertIsNotNone(can)
212216

@@ -219,8 +223,9 @@ def test_image(self):
219223
rb.click()
220224
out = t2.find_element_by_id("ac14_7_2_stdout")
221225
self.assertIsNotNone(out)
226+
time.sleep(1)
222227
self.assertTrue("400" in out.text)
223228
self.assertTrue("244" in out.text)
224-
self.assertTrue("165 161 158" in out.text)
229+
self.assertTrue(("165 161 158" in out.text) or ("165 162 157" in out.text))
225230
can = t2.find_element_by_tag_name("canvas")
226231
self.assertIsNotNone(can)

0 commit comments

Comments
 (0)