1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
from __future__ import annotations
from datetime import time
import pendulum
from tests.conftest import assert_time
def test_equal_to_true():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert t1 == t2
assert t1 == t3
def test_equal_to_false():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 4)
t3 = time(1, 2, 4)
assert t1 != t2
assert t1 != t3
def test_not_equal_to_none():
t1 = pendulum.time(1, 2, 3)
assert t1 is not None
def test_greater_than_true():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 2)
t3 = time(1, 2, 2)
assert t1 > t2
assert t1 > t3
def test_greater_than_false():
t1 = pendulum.time(1, 2, 2)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert not t1 > t2
assert not t1 > t3
def test_greater_than_or_equal_true():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 2)
t3 = time(1, 2, 2)
assert t1 >= t2
assert t1 >= t3
def test_greater_than_or_equal_true_equal():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert t1 >= t2
assert t1 >= t3
def test_greater_than_or_equal_false():
t1 = pendulum.time(1, 2, 2)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert not t1 >= t2
assert not t1 >= t3
def test_less_than_true():
t1 = pendulum.time(1, 2, 2)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert t1 < t2
assert t1 < t3
def test_less_than_false():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 2)
t3 = time(1, 2, 2)
assert not t1 < t2
assert not t1 < t3
def test_less_than_or_equal_true():
t1 = pendulum.time(1, 2, 2)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert t1 <= t2
assert t1 <= t3
def test_less_than_or_equal_true_equal():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 3)
t3 = time(1, 2, 3)
assert t1 <= t2
assert t1 <= t3
def test_less_than_or_equal_false():
t1 = pendulum.time(1, 2, 3)
t2 = pendulum.time(1, 2, 2)
t3 = time(1, 2, 2)
assert not t1 <= t2
assert not t1 <= t3
def test_closest():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 54)
t2 = pendulum.time(12, 34, 59)
closest = instance.closest(t1, t2)
assert t1 == closest
closest = instance.closest(t2, t1)
assert t1 == closest
def test_closest_with_time():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 54)
t2 = pendulum.time(12, 34, 59)
closest = instance.closest(t1, t2)
assert_time(closest, 12, 34, 54)
def test_closest_with_equals():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 56)
t2 = pendulum.time(12, 34, 59)
closest = instance.closest(t1, t2)
assert t1 == closest
def test_farthest():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 54)
t2 = pendulum.time(12, 34, 59)
farthest = instance.farthest(t1, t2)
assert t2 == farthest
farthest = instance.farthest(t2, t1)
assert t2 == farthest
def test_farthest_with_time():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 54)
t2 = pendulum.time(12, 34, 59)
farthest = instance.farthest(t1, t2)
assert_time(farthest, 12, 34, 59)
def test_farthest_with_equals():
instance = pendulum.time(12, 34, 56)
t1 = pendulum.time(12, 34, 56)
t2 = pendulum.time(12, 34, 59)
farthest = instance.farthest(t1, t2)
assert t2 == farthest
def test_comparison_to_unsupported():
t1 = pendulum.now().time()
assert t1 != "test"
assert t1 not in ["test"]
|