Skip to content

Commit

Permalink
TST: Only assert loud failure if convergence fails
Browse files Browse the repository at this point in the history
  • Loading branch information
scottclowe committed Jul 10, 2021
1 parent c91e4a4 commit 4233521
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions fissa/tests/test_neuropil.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def run_method(self, method, expected_converged=None, **kwargs):
# If specified, assert that the result is as expected
if expected_converged is not None:
self.assert_equal(convergence["converged"], expected_converged)
return convergence["converged"]

def test_method(self):
self.run_method(self.method, expected_converged=True, max_tries=1)
Expand Down Expand Up @@ -72,11 +73,16 @@ def test_retry_loud(self):
capture_pre = self.capsys.readouterr() # Clear stdout
with warnings.catch_warnings():
warnings.simplefilter("ignore")
self.run_method(self.method, max_iter=1, max_tries=3, verbosity=1)
converged = self.run_method(
self.method, max_iter=1, max_tries=3, verbosity=1
)
capture_post = self.recapsys(capture_pre) # Capture and then re-output
self.assertTrue("Attempt 1 failed to converge at " in capture_post.out)
self.assertTrue("Trying a new random state." in capture_post.out)
self.assertTrue("aximum number of allowed tries reached" in capture_post.out)
if not converged:
self.assertTrue("Attempt 1 failed to converge at " in capture_post.out)
self.assertTrue("Trying a new random state." in capture_post.out)
self.assertTrue(
"aximum number of allowed tries reached" in capture_post.out
)

def test_retry_quiet(self):
capture_pre = self.capsys.readouterr() # Clear stdout
Expand Down

0 comments on commit 4233521

Please sign in to comment.