From 02f8c111094e4b44c6b7bb853d0ddfde761ec6a8 Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Mon, 23 Oct 2023 09:42:22 -0700 Subject: [PATCH] cov --- src/hdmf/term_set.py | 8 ++++---- tests/unit/example_test_term_set.yaml | 3 +++ tests/unit/test_term_set.py | 7 ++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/hdmf/term_set.py b/src/hdmf/term_set.py index 74d94729e..f185c8fc0 100644 --- a/src/hdmf/term_set.py +++ b/src/hdmf/term_set.py @@ -62,11 +62,11 @@ def __repr__(self): re = "Schema Path: %s\n" % self.term_schema_path re += "Sources: " + ", ".join(list(self.sources.keys()))+"\n" re += "Terms: \n" - i = 0 + i = 1 for term in terms: if i>4: break - elif i==2: + elif i==3: re += " ... ... \n" re += " - %s\n" % term i += 1 @@ -79,11 +79,11 @@ def _repr_html_(self): re = "" + "Schema Path: " + "" + self.term_schema_path + "
" re += "" + "Sources: " + "" + ", ".join(list(self.sources.keys())) + "
" re += " Terms: " - i = 0 + i = 1 for term in terms: if i>4: break - elif i==2: + elif i==3: re += "... ..." re += "
  • %s
  • " % term i += 1 diff --git a/tests/unit/example_test_term_set.yaml b/tests/unit/example_test_term_set.yaml index 6595cdc0b..b15bc7df5 100644 --- a/tests/unit/example_test_term_set.yaml +++ b/tests/unit/example_test_term_set.yaml @@ -22,3 +22,6 @@ enums: Myrmecophaga tridactyla: description: the species is an anteater meaning: NCBI_TAXON:71006 + Panda: + description: the species is panda + meaning: NCBI_TAXON:212257 diff --git a/tests/unit/test_term_set.py b/tests/unit/test_term_set.py index 222537f01..b45e47e6a 100644 --- a/tests/unit/test_term_set.py +++ b/tests/unit/test_term_set.py @@ -33,7 +33,7 @@ def test_repr(self): termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml') output = ('Schema Path: tests/unit/example_test_term_set.yaml\nSources: NCBI_TAXON\nTerms: \n'+ ' - Homo sapiens\n - Mus musculus\n ... ... \n - Ursus arctos horribilis\n'+ - ' - Myrmecophaga tridactyla\nNumber of terms: 4') + ' - Myrmecophaga tridactyla\nNumber of terms: 5') self.assertEqual(repr(termset), output) def test_repr_html(self): @@ -41,12 +41,13 @@ def test_repr_html(self): output = ('Schema Path: tests/unit/example_test_term_set.yaml
    Sources:'+ ' NCBI_TAXON
    Terms:
  • Homo sapiens
  • Mus musculus'+ '
  • ... ...
  • Ursus arctos horribilis
  • Myrmecophaga tridactyla'+ - '
  • Number of terms: 4') + ' Number of terms: 5') self.assertEqual(termset._repr_html_(), output) def test_view_set(self): termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml') - expected = ['Homo sapiens', 'Mus musculus', 'Ursus arctos horribilis', 'Myrmecophaga tridactyla'] + expected = ['Homo sapiens', 'Mus musculus', 'Ursus arctos horribilis', 'Myrmecophaga tridactyla', + 'Panda'] self.assertEqual(list(termset.view_set), expected) self.assertIsInstance(termset.view, SchemaView)