diff --git a/lmfdb/tests/__init__.py b/lmfdb/tests/__init__.py index 00f510832b..72e1accf64 100644 --- a/lmfdb/tests/__init__.py +++ b/lmfdb/tests/__init__.py @@ -79,18 +79,19 @@ def assert_if_magma(self, expected, magma_code, mode='equal'): equality only if magma is installed; if it isn't, then the test passes.""" from sage.all import magma + has_magma = False try: + has_magma = "2" == magma.eval("1 + 1") + except (RuntimeError, TypeError): + pass + + if has_magma: if mode == 'equal': assert expected == magma.eval(magma_code) elif mode == 'in': assert expected in magma.eval(magma_code) else: raise ValueError("mode must be either 'equal' or 'in") - except RuntimeError as the_error: - if str(the_error).startswith("unable to start magma"): - pass - else: - raise def check_sage_compiles_and_extract_variables(self, sage_code): """ diff --git a/lmfdb/tests/test_utils.py b/lmfdb/tests/test_utils.py index 387820dad1..2150238de2 100644 --- a/lmfdb/tests/test_utils.py +++ b/lmfdb/tests/test_utils.py @@ -122,7 +122,7 @@ def test_signtocolour(self): Checking utility: signtocolour """ self.assertEqual(signtocolour(0), 'rgb(63,63,255)') - self.assertEqual(signtocolour(1+2j), 'rgb(197,0,184)') + self.assertEqual(signtocolour("1+2*I"), 'rgb(197,0,184)') def test_rgbtohex(self): r"""