Skip to content

Commit

Permalink
Merge pull request #5695 from edgarcosta/has_magma
Browse files Browse the repository at this point in the history
separate the logic of having magma and testing magma code
  • Loading branch information
roed314 authored Oct 14, 2023
2 parents da200e1 + be54723 commit 7b444b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lmfdb/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 1 addition & 1 deletion lmfdb/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 7b444b0

Please sign in to comment.