Coverage for tests/objects/test_classification.py: 100%
40 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-10-22 18:11 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-10-22 18:11 +0000
1from qubalab.objects.classification import Classification
4def test_name():
5 expected_names = ("name",)
6 classification = Classification(expected_names)
8 names = classification.names
10 assert expected_names == names
13def test_color():
14 expected_color = (2, 20, 56)
15 classification = Classification("name", expected_color)
17 color = classification.color
19 assert expected_color == color
22def test_None_when_names_is_None():
23 classification = Classification(None)
24 assert classification is None
27def test_cache_when_empty():
28 name = "name"
29 color = (2, 20, 56)
31 classification = Classification(name, color)
33 assert classification is Classification(name, color)
36def test_cache_when_not_empty_and_same_name():
37 cached_name = "name"
38 cached_color = (2, 20, 56)
39 other_name = cached_name
40 other_color = (4, 65, 7)
41 cached_classification = Classification(cached_name, cached_color)
43 classification = Classification(other_name, other_color)
45 assert (
46 classification is Classification(other_name, other_color)
47 and classification is cached_classification
48 )
51def test_cache_when_not_empty_and_different_name():
52 cached_name = "name"
53 cached_color = (2, 20, 56)
54 other_name = "other name"
55 other_color = (4, 65, 7)
56 cached_classification = Classification(cached_name, cached_color)
58 classification = Classification(other_name, other_color)
60 assert (
61 classification == Classification(other_name, other_color)
62 and classification != cached_classification
63 )
66def test_names_input():
67 names = ("a", "b")
68 class1 = Classification(names)
69 class2 = Classification(list(names))
70 assert class1 is class2