This commit is contained in:
2026-09-06 12:26:53 +02:00
parent bbe1406afb
commit d2d7c7fa74
8 changed files with 179 additions and 51 deletions
+12 -4
View File
@@ -7,6 +7,7 @@ def test_single_level_category():
assert c.name == "single"
assert c.parent is None
def test_two_level_category():
c = Category.from_str("first:second")
assert c
@@ -15,6 +16,7 @@ def test_two_level_category():
assert c.parent.name == "first"
assert c.parent.parent is None
def test_three_level_category():
c = Category.from_str("first:second:third")
assert c
@@ -25,24 +27,30 @@ def test_three_level_category():
assert c.parent.parent.name == "first"
assert c.parent.parent.parent is None
def test_single_level_category_to_string():
c = Category.from_str("single")
assert c
assert str(c) == "single"
def test_two_level_category_to_string():
c = Category(name = "second", parent=Category(name = "first"))
c = Category(name="second", parent=Category(name="first"))
assert c.to_str() == "first:second"
def test_three_level_category_to_string():
c = Category(name = "third", parent=Category(name = "second", parent=Category(name="first")))
c = Category(
name="third", parent=Category(name="second", parent=Category(name="first"))
)
assert c.to_str() == "first:second:third"
def test_category_str():
c = Category.from_str("first:second:third")
assert str(c) == "first:second:third"
def test_category_repr():
c = Category.from_str("first:second:third")
assert repr(c) == "Category.from_str(\"first:second:third\")"
assert repr(c) == 'Category.from_str("first:second:third")'