diff --git a/pytaxonomies/api.py b/pytaxonomies/api.py index 679eea3..8d8003d 100644 --- a/pytaxonomies/api.py +++ b/pytaxonomies/api.py @@ -135,8 +135,10 @@ class Taxonomy(collections.Mapping): return to_return def has_entries(self): - if self.predicates.values() and list(self.predicates.values())[0].entries: - return True + if self.predicates.values(): + for p in self.predicates.values(): + if p.entries: + return True return False def __str__(self): diff --git a/tests/tests.py b/tests/tests.py index 04c338d..2ff8867 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -50,13 +50,12 @@ class TestPyTaxonomies(unittest.TestCase): self.taxonomies.search('phish', expanded=True) def test_print_classes(self): - for t in self.taxonomies.values(): - if not t.has_entries(): - continue - tax = list(t.values())[0] - print(tax) - pred = list(tax.values())[0] - print(pred) + for taxonomy in self.taxonomies.values(): + print(taxonomy) + for predicate in taxonomy.values(): + print(predicate) + for entry in predicate.values(): + print(entry) def test_amountEntries(self): list(self.taxonomies.values())[0].amount_entries()