diff --git a/src/hdmf/term_set.py b/src/hdmf/term_set.py index 7a6615c8d..baf014140 100644 --- a/src/hdmf/term_set.py +++ b/src/hdmf/term_set.py @@ -56,12 +56,12 @@ def __init__(self, self.name = self.view.schema.name self.sources = self.view.schema.prefixes - def __repr__(self): # pragma: no cover + def __repr__(self): re = "Schema Path: %s\n" % self.term_schema_path re += "Sources: " + ", ".join(list(self.sources.keys())) return re - def _repr_html_(self): # pragma: no cover + def _repr_html_(self): re = "

" + "Schema Path: " + "" + self.term_schema_path + "
" + "

" re += "

" + "Sources: " + "" + ", ".join(list(self.sources.keys())) + "

" return re diff --git a/tests/unit/test_term_set.py b/tests/unit/test_term_set.py index ccadb0321..0af4adc0a 100644 --- a/tests/unit/test_term_set.py +++ b/tests/unit/test_term_set.py @@ -29,6 +29,16 @@ def test_termset_setup(self): self.assertEqual(termset.name, 'Species') self.assertEqual(list(termset.sources), ['NCBI_TAXON']) + 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' + self.assertEqual(repr(termset), output) + + def test_repr_html(self): + termset = TermSet(term_schema_path='tests/unit/example_test_term_set.yaml') + output = '

Schema Path: tests/unit/example_test_term_set.yaml

Sources: NCBI_TAXON

' + 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']