|
3 | 3 | from ontouml_py.classes.utils.nonemptyset import NonEmptySet |
4 | 4 |
|
5 | 5 |
|
6 | | -def test_nonemptyset_initialization(): |
| 6 | +def test_nonemptyset_initialization() -> None: |
7 | 7 | """Test initialization of NonEmptySet with non-empty set.""" |
8 | 8 | non_empty_set = NonEmptySet({1, 2, 3}) |
9 | 9 | assert len(non_empty_set) == 3, "NonEmptySet should initialize with the correct number of elements" |
10 | 10 |
|
11 | 11 |
|
12 | | -def test_nonemptyset_initialization_empty_set(): |
| 12 | +def test_nonemptyset_initialization_empty_set() -> None: |
13 | 13 | """Test initialization of NonEmptySet with an empty set raises ValueError.""" |
14 | 14 | with pytest.raises(ValueError, match="Initial set cannot be empty."): |
15 | 15 | NonEmptySet(set()) |
16 | 16 |
|
17 | 17 |
|
18 | | -def test_nonemptyset_add_element(): |
| 18 | +def test_nonemptyset_add_element() -> None: |
19 | 19 | """Test adding an element to the NonEmptySet.""" |
20 | 20 | non_empty_set = NonEmptySet({1}) |
21 | 21 | non_empty_set.add(2) |
22 | 22 | assert 2 in non_empty_set, "Element should be added to NonEmptySet" |
23 | 23 |
|
24 | 24 |
|
25 | | -def test_nonemptyset_remove_element(): |
| 25 | +def test_nonemptyset_remove_element() -> None: |
26 | 26 | """Test removing an element from the NonEmptySet.""" |
27 | 27 | non_empty_set = NonEmptySet({1, 2}) |
28 | 28 | non_empty_set.remove(1) |
29 | 29 | assert 1 not in non_empty_set, "Element should be removed from NonEmptySet" |
30 | 30 |
|
31 | 31 |
|
32 | | -def test_nonemptyset_remove_last_element(): |
| 32 | +def test_nonemptyset_remove_last_element() -> None: |
33 | 33 | """Test removing the last element from the NonEmptySet raises ValueError.""" |
34 | 34 | non_empty_set = NonEmptySet({1}) |
35 | 35 | with pytest.raises(ValueError, match="Cannot remove the last element from the set."): |
36 | 36 | non_empty_set.remove(1) |
37 | 37 |
|
38 | 38 |
|
39 | | -def test_nonemptyset_update(): |
| 39 | +def test_nonemptyset_update() -> None: |
40 | 40 | """Test updating NonEmptySet with another set.""" |
41 | 41 | non_empty_set = NonEmptySet({1}) |
42 | 42 | non_empty_set.update({2, 3}) |
43 | 43 | assert non_empty_set == NonEmptySet({1, 2, 3}), "NonEmptySet should be updated correctly" |
44 | 44 |
|
45 | 45 |
|
46 | | -def test_nonemptyset_discard_existing_element(): |
| 46 | +def test_nonemptyset_discard_existing_element() -> None: |
47 | 47 | """Test discarding an existing element from NonEmptySet.""" |
48 | 48 | non_empty_set = NonEmptySet({1, 2}) |
49 | 49 | non_empty_set.discard(1) |
50 | 50 | assert 1 not in non_empty_set, "Existing element should be discarded from NonEmptySet" |
51 | 51 |
|
52 | 52 |
|
53 | | -def test_nonemptyset_discard_last_element(): |
| 53 | +def test_nonemptyset_discard_last_element() -> None: |
54 | 54 | """Test discarding the last element from NonEmptySet raises ValueError.""" |
55 | 55 | non_empty_set = NonEmptySet({1}) |
56 | 56 | with pytest.raises(ValueError, match="Cannot discard the last element from the set."): |
57 | 57 | non_empty_set.discard(1) |
58 | 58 |
|
59 | 59 |
|
60 | | -def test_nonemptyset_pop_element(): |
| 60 | +def test_nonemptyset_pop_element() -> None: |
61 | 61 | """Test popping an element from NonEmptySet.""" |
62 | 62 | non_empty_set = NonEmptySet({1, 2}) |
63 | 63 | popped = non_empty_set.pop() |
64 | 64 | assert popped in {1, 2}, "Popped element should be from NonEmptySet" |
65 | 65 | assert len(non_empty_set) == 1, "NonEmptySet should have one less element after pop" |
66 | 66 |
|
67 | 67 |
|
68 | | -def test_nonemptyset_pop_last_element(): |
| 68 | +def test_nonemptyset_pop_last_element() -> None: |
69 | 69 | """Test popping the last element from NonEmptySet raises ValueError.""" |
70 | 70 | non_empty_set = NonEmptySet({1}) |
71 | 71 | with pytest.raises(ValueError, match="Cannot pop the last element from the set."): |
72 | 72 | non_empty_set.pop() |
73 | 73 |
|
74 | 74 |
|
75 | | -def test_nonemptyset_clear(): |
| 75 | +def test_nonemptyset_clear() -> None: |
76 | 76 | """Test clearing NonEmptySet raises ValueError.""" |
77 | 77 | non_empty_set = NonEmptySet({1, 2, 3}) |
78 | 78 | with pytest.raises(ValueError, match="Cannot clear a NonEmptySet."): |
79 | 79 | non_empty_set.clear() |
80 | 80 |
|
81 | 81 |
|
82 | | -def test_nonemptyset_convert_set(): |
| 82 | +def test_nonemptyset_convert_set() -> None: |
83 | 83 | """Test converting a regular set to NonEmptySet.""" |
84 | 84 | regular_set = {1, 2, 3} |
85 | 85 | non_empty_set = NonEmptySet.convert_set(regular_set) |
86 | 86 | assert non_empty_set == NonEmptySet({1, 2, 3}), "NonEmptySet should be correctly created from a regular set" |
87 | 87 |
|
88 | 88 |
|
89 | | -def test_nonemptyset_convert_empty_set(): |
| 89 | +def test_nonemptyset_convert_empty_set() -> None: |
90 | 90 | """Test converting an empty set to NonEmptySet raises ValueError.""" |
91 | 91 | with pytest.raises(ValueError, match="Cannot create a NonEmptySet from an empty set"): |
92 | 92 | NonEmptySet.convert_set(set()) |
93 | 93 |
|
94 | 94 |
|
95 | | -def test_nonemptyset_str_representation(): |
| 95 | +def test_nonemptyset_str_representation() -> None: |
96 | 96 | """Test the string representation of NonEmptySet.""" |
97 | 97 | non_empty_set = NonEmptySet({1, 2, 3}) |
98 | 98 | assert str(non_empty_set) == "{1, 2, 3}", "String representation of NonEmptySet should be correct" |
99 | 99 |
|
100 | 100 |
|
101 | | -def test_nonemptyset_repr_representation(): |
| 101 | +def test_nonemptyset_repr_representation() -> None: |
102 | 102 | """Test the official string representation of NonEmptySet.""" |
103 | 103 | non_empty_set = NonEmptySet({1, 2}) |
104 | 104 | assert ( |
|
0 commit comments