(make_timeline)
| 68 | |
| 69 | @pytest.mark.timeout(1) |
| 70 | def test_occurrences(make_timeline): |
| 71 | timeline, initial_history = make_timeline() |
| 72 | |
| 73 | mark1 = timeline.mark("dum") |
| 74 | mark2 = timeline.mark("dee") |
| 75 | mark3 = timeline.mark("dum") |
| 76 | |
| 77 | assert mark1 == Mark("dum") |
| 78 | assert mark1.id == "dum" |
| 79 | assert mark2 == Mark("dee") |
| 80 | assert mark2.id == "dee" |
| 81 | assert mark3 == Mark("dum") |
| 82 | assert mark3.id == "dum" |
| 83 | |
| 84 | with timeline.frozen(): |
| 85 | assert timeline.history() == initial_history + [ |
| 86 | some.object.same_as(mark1), |
| 87 | some.object.same_as(mark2), |
| 88 | some.object.same_as(mark3), |
| 89 | ] |
| 90 | timeline.finalize() |
| 91 | |
| 92 | assert timeline.all_occurrences_of(Mark("dum")) == ( |
| 93 | some.object.same_as(mark1), |
| 94 | some.object.same_as(mark3), |
| 95 | ) |
| 96 | assert timeline.all_occurrences_of(Mark("dee")) == (some.object.same_as(mark2),) |
| 97 | |
| 98 | assert timeline[:].all_occurrences_of(Mark("dum")) == ( |
| 99 | some.object.same_as(mark1), |
| 100 | some.object.same_as(mark3), |
| 101 | ) |
| 102 | |
| 103 | # Lower boundary is inclusive. |
| 104 | assert timeline[mark1:].all_occurrences_of(Mark("dum")) == ( |
| 105 | some.object.same_as(mark1), |
| 106 | some.object.same_as(mark3), |
| 107 | ) |
| 108 | assert timeline[mark2:].all_occurrences_of(Mark("dum")) == ( |
| 109 | some.object.same_as(mark3), |
| 110 | ) |
| 111 | assert timeline[mark3:].all_occurrences_of(Mark("dum")) == ( |
| 112 | some.object.same_as(mark3), |
| 113 | ) |
| 114 | |
| 115 | # Upper boundary is exclusive. |
| 116 | assert timeline[:mark1].all_occurrences_of(Mark("dum")) == () |
| 117 | assert timeline[:mark2].all_occurrences_of(Mark("dum")) == ( |
| 118 | some.object.same_as(mark1), |
| 119 | ) |
| 120 | assert timeline[:mark3].all_occurrences_of(Mark("dum")) == ( |
| 121 | some.object.same_as(mark1), |
| 122 | ) |
| 123 | |
| 124 | |
| 125 | def expectation_of(message): |
nothing calls this directly
no test coverage detected
searching dependent graphs…