Skip to content
Browse files

fixed up test code some.

  • Loading branch information...
1 parent 1336897 commit 6f6966df7e73302f1c8acd4c7ab668c29b7f2b2e @timo committed Oct 17, 2012
Showing with 7 additions and 33 deletions.
  1. +1 −1 test/test_cagen.py
  2. +1 −0 test/test_dualrule.py
  3. +5 −32 test/test_gui.py
View
2 test/test_cagen.py
@@ -53,7 +53,7 @@ def test_immutability(self):
with pytest.raises(AssertionError):
br._step_func.set_target(br)
with pytest.raises(AttributeError):
- br._step_func.add_weave_code("headers", "int foo = 42")
+ br._step_func.add_weave_code("pre_compute", "int foo = 42")
with pytest.raises(AttributeError):
br._step_func.add_py_code("pre_compute", "print 'hello'")
View
1 test/test_dualrule.py
@@ -26,6 +26,7 @@ def test_run_nondeterministic_weave(self):
# implement nazim fatès density classifier
compu = cagen.DualRuleCellularAutomaton(184, 232, 0.1)
sf = cagen.automatic_stepfunc(computation=compu, histogram=True, needs_random_generator=True)
+ sf.gen_code()
simu = CagenSimulator(sf)
for i in range(50):
View
37 test/test_gui.py
@@ -45,12 +45,16 @@ def my_abort_hook():
_aborts.append(True)
def fail_on_exceptions():
+ import traceback
exc = _exceptions[:]
[_exceptions.remove(a) for a in exc]
aborts = _aborts[:]
[_aborts.remove(a) for a in aborts]
if exc:
- pytest.fail("There were exceptions in the base.\n%s" % (exc[0]))
+ exceptiontext = []
+ for exception in exc:
+ exceptiontext.extend(traceback.format_exception(*exception))
+ pytest.fail("There were exceptions in the base.\n%s" % "\n".join(exceptiontext))
if aborts:
pytest.fail("There were abort signals in the tests.")
@@ -108,37 +112,6 @@ def test_start_stop_binrule(self, size, base, scale, histogram):
self.app.closeAllWindows()
fail_on_exceptions()
- def test_reset_button(self):
- sim_obj = cagen.ElementarySimulator((100, 100), copy_borders=True, base=3)
-
- display = ZasimDisplay(sim_obj)
- display.set_scale(1)
-
- QTest.qWaitForWindowShown(display.window)
-
- reset_button = display.control.findChild(QWidget, u"reset")
- assert reset_button is not None
-
- display.control.zero_percentage.setValue(0.33)
- QTest.mouseClick(reset_button, Qt.LeftButton)
-
- config = sim_obj.get_config()
- histogram = np.bincount(config.ravel())
- zeros = histogram[0]
- other = sum(histogram[1:])
- assert abs((1.0 * zeros / (zeros + other)) - 0.33) < 0.2
-
- display.control.zero_percentage.setValue(0.99)
- QTest.mouseClick(reset_button, Qt.LeftButton)
-
- config = sim_obj.get_config()
- histogram = np.bincount(config.ravel())
- zeros = histogram[0]
- other = sum(histogram[1:])
- assert abs((1.0 * zeros / (zeros + other)) - 0.99) < 0.2
-
- fail_on_exceptions()
-
def find_message_box(self, timeout=10):
end = time.time() + timeout
while time.time() < end:

0 comments on commit 6f6966d

Please sign in to comment.
Something went wrong with that request. Please try again.