From 149fce0a7eb8c5149ab1e5302bea2816034b0cf5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 14 Nov 2020 19:24:31 +0100 Subject: [PATCH] increase test coverage --- python/damask/util.py | 13 ++----------- python/tests/test_Table.py | 6 ++++++ python/tests/test_util.py | 8 ++++++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index d02877f8f..fa983d64e 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -56,6 +56,8 @@ def croak(what, newline = True): """ Write formated to stderr. + DEPRECATED + Parameters ---------- what : str or iterable @@ -393,17 +395,6 @@ class bcolors: UNDERLINE = '\033[4m' CROSSOUT = '\033[9m' - def disable(self): - self.HEADER = '' - self.OKBLUE = '' - self.OKGREEN = '' - self.WARNING = '' - self.FAIL = '' - self.ENDC = '' - self.BOLD = '' - self.UNDERLINE = '' - self.CROSSOUT = '' - class return_message: """Object with formatted return message.""" diff --git a/python/tests/test_Table.py b/python/tests/test_Table.py index 9dad681bd..8c4465dc1 100644 --- a/python/tests/test_Table.py +++ b/python/tests/test_Table.py @@ -17,6 +17,12 @@ def reference_dir(reference_dir_base): class TestTable: + def test_repr(self,default): + print(default) + + def test_len(self): + len(Table(np.random.rand(7,3),{'X':3})) == 7 + def test_get_scalar(self,default): d = default.get('s') assert np.allclose(d,1.0) and d.shape[1:] == (1,) diff --git a/python/tests/test_util.py b/python/tests/test_util.py index 19b6377f6..9906689e9 100644 --- a/python/tests/test_util.py +++ b/python/tests/test_util.py @@ -15,6 +15,10 @@ class TestUtil: out,err = util.execute('sh -c "echo $test_for_execute"',env={'test_for_execute':'test'}) assert out=='test\n' and err=='' + def test_execute_invalid(self): + with pytest.raises(RuntimeError): + util.execute('/bin/false') + def test_croak(self): util.croak('Burp!') @@ -93,3 +97,7 @@ class TestUtil: ]) def test_shapeblender(self,a,b,answer): assert util.shapeblender(a,b) == answer + + @pytest.mark.parametrize('style',[util.emph,util.deemph,util.delete,util.strikeout]) + def test_decorate(self,style): + assert 'DAMASK' in style('DAMASK')