File: test_arrow.py

package info (click to toggle)
python-arrow 1.3.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 932 kB
  • sloc: python: 14,371; makefile: 67
file content (2918 lines) | stat: -rw-r--r-- 101,984 bytes parent folder | download
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
import pickle
import sys
import time
from datetime import date, datetime, timedelta
from typing import List

import dateutil
import pytest
import pytz
import simplejson as json
from dateutil import tz
from dateutil.relativedelta import FR, MO, SA, SU, TH, TU, WE

from arrow import arrow, locales

from .utils import assert_datetime_equality


class TestTestArrowInit:
    def test_init_bad_input(self):
        with pytest.raises(TypeError):
            arrow.Arrow(2013)

        with pytest.raises(TypeError):
            arrow.Arrow(2013, 2)

        with pytest.raises(ValueError):
            arrow.Arrow(2013, 2, 2, 12, 30, 45, 9999999)

    def test_init(self):
        result = arrow.Arrow(2013, 2, 2)
        self.expected = datetime(2013, 2, 2, tzinfo=tz.tzutc())
        assert result._datetime == self.expected

        result = arrow.Arrow(2013, 2, 2, 12)
        self.expected = datetime(2013, 2, 2, 12, tzinfo=tz.tzutc())
        assert result._datetime == self.expected

        result = arrow.Arrow(2013, 2, 2, 12, 30)
        self.expected = datetime(2013, 2, 2, 12, 30, tzinfo=tz.tzutc())
        assert result._datetime == self.expected

        result = arrow.Arrow(2013, 2, 2, 12, 30, 45)
        self.expected = datetime(2013, 2, 2, 12, 30, 45, tzinfo=tz.tzutc())
        assert result._datetime == self.expected

        result = arrow.Arrow(2013, 2, 2, 12, 30, 45, 999999)
        self.expected = datetime(2013, 2, 2, 12, 30, 45, 999999, tzinfo=tz.tzutc())
        assert result._datetime == self.expected

        result = arrow.Arrow(
            2013, 2, 2, 12, 30, 45, 999999, tzinfo=tz.gettz("Europe/Paris")
        )
        self.expected = datetime(
            2013, 2, 2, 12, 30, 45, 999999, tzinfo=tz.gettz("Europe/Paris")
        )
        assert result._datetime == self.expected

    # regression tests for issue #626
    def test_init_pytz_timezone(self):
        result = arrow.Arrow(
            2013, 2, 2, 12, 30, 45, 999999, tzinfo=pytz.timezone("Europe/Paris")
        )
        self.expected = datetime(
            2013, 2, 2, 12, 30, 45, 999999, tzinfo=tz.gettz("Europe/Paris")
        )
        assert result._datetime == self.expected
        assert_datetime_equality(result._datetime, self.expected, 1)

    def test_init_with_fold(self):
        before = arrow.Arrow(2017, 10, 29, 2, 0, tzinfo="Europe/Stockholm")
        after = arrow.Arrow(2017, 10, 29, 2, 0, tzinfo="Europe/Stockholm", fold=1)

        assert hasattr(before, "fold")
        assert hasattr(after, "fold")

        # PEP-495 requires the comparisons below to be true
        assert before == after
        assert before.utcoffset() != after.utcoffset()


class TestTestArrowFactory:
    def test_now(self):
        result = arrow.Arrow.now()

        assert_datetime_equality(
            result._datetime, datetime.now().replace(tzinfo=tz.tzlocal())
        )

    def test_utcnow(self):
        result = arrow.Arrow.utcnow()

        assert_datetime_equality(
            result._datetime, datetime.utcnow().replace(tzinfo=tz.tzutc())
        )

        assert result.fold == 0

    def test_fromtimestamp(self):
        timestamp = time.time()

        result = arrow.Arrow.fromtimestamp(timestamp)
        assert_datetime_equality(
            result._datetime, datetime.now().replace(tzinfo=tz.tzlocal())
        )

        result = arrow.Arrow.fromtimestamp(timestamp, tzinfo=tz.gettz("Europe/Paris"))
        assert_datetime_equality(
            result._datetime,
            datetime.fromtimestamp(timestamp, tz.gettz("Europe/Paris")),
        )

        result = arrow.Arrow.fromtimestamp(timestamp, tzinfo="Europe/Paris")
        assert_datetime_equality(
            result._datetime,
            datetime.fromtimestamp(timestamp, tz.gettz("Europe/Paris")),
        )

        with pytest.raises(ValueError):
            arrow.Arrow.fromtimestamp("invalid timestamp")

    def test_utcfromtimestamp(self):
        timestamp = time.time()

        result = arrow.Arrow.utcfromtimestamp(timestamp)
        assert_datetime_equality(
            result._datetime, datetime.utcnow().replace(tzinfo=tz.tzutc())
        )

        with pytest.raises(ValueError):
            arrow.Arrow.utcfromtimestamp("invalid timestamp")

    def test_fromdatetime(self):
        dt = datetime(2013, 2, 3, 12, 30, 45, 1)

        result = arrow.Arrow.fromdatetime(dt)

        assert result._datetime == dt.replace(tzinfo=tz.tzutc())

    def test_fromdatetime_dt_tzinfo(self):
        dt = datetime(2013, 2, 3, 12, 30, 45, 1, tzinfo=tz.gettz("US/Pacific"))

        result = arrow.Arrow.fromdatetime(dt)

        assert result._datetime == dt.replace(tzinfo=tz.gettz("US/Pacific"))

    def test_fromdatetime_tzinfo_arg(self):
        dt = datetime(2013, 2, 3, 12, 30, 45, 1)

        result = arrow.Arrow.fromdatetime(dt, tz.gettz("US/Pacific"))

        assert result._datetime == dt.replace(tzinfo=tz.gettz("US/Pacific"))

    def test_fromdate(self):
        dt = date(2013, 2, 3)

        result = arrow.Arrow.fromdate(dt, tz.gettz("US/Pacific"))

        assert result._datetime == datetime(2013, 2, 3, tzinfo=tz.gettz("US/Pacific"))

    def test_strptime(self):
        formatted = datetime(2013, 2, 3, 12, 30, 45).strftime("%Y-%m-%d %H:%M:%S")

        result = arrow.Arrow.strptime(formatted, "%Y-%m-%d %H:%M:%S")
        assert result._datetime == datetime(2013, 2, 3, 12, 30, 45, tzinfo=tz.tzutc())

        result = arrow.Arrow.strptime(
            formatted, "%Y-%m-%d %H:%M:%S", tzinfo=tz.gettz("Europe/Paris")
        )
        assert result._datetime == datetime(
            2013, 2, 3, 12, 30, 45, tzinfo=tz.gettz("Europe/Paris")
        )

    def test_fromordinal(self):
        timestamp = 1607066909.937968
        with pytest.raises(TypeError):
            arrow.Arrow.fromordinal(timestamp)
        with pytest.raises(ValueError):
            arrow.Arrow.fromordinal(int(timestamp))

        ordinal = arrow.Arrow.utcnow().toordinal()

        with pytest.raises(TypeError):
            arrow.Arrow.fromordinal(str(ordinal))

        result = arrow.Arrow.fromordinal(ordinal)
        dt = datetime.fromordinal(ordinal)

        assert result.naive == dt


@pytest.mark.usefixtures("time_2013_02_03")
class TestTestArrowRepresentation:
    def test_repr(self):
        result = self.arrow.__repr__()

        assert result == f"<Arrow [{self.arrow._datetime.isoformat()}]>"

    def test_str(self):
        result = self.arrow.__str__()

        assert result == self.arrow._datetime.isoformat()

    def test_hash(self):
        result = self.arrow.__hash__()

        assert result == self.arrow._datetime.__hash__()

    def test_format(self):
        result = f"{self.arrow:YYYY-MM-DD}"

        assert result == "2013-02-03"

    def test_bare_format(self):
        result = self.arrow.format()

        assert result == "2013-02-03 12:30:45+00:00"

    def test_format_no_format_string(self):
        result = f"{self.arrow}"

        assert result == str(self.arrow)

    def test_clone(self):
        result = self.arrow.clone()

        assert result is not self.arrow
        assert result._datetime == self.arrow._datetime


@pytest.mark.usefixtures("time_2013_01_01")
class TestArrowAttribute:
    def test_getattr_base(self):
        with pytest.raises(AttributeError):
            self.arrow.prop

    def test_getattr_week(self):
        assert self.arrow.week == 1

    def test_getattr_quarter(self):
        # start dates
        q1 = arrow.Arrow(2013, 1, 1)
        q2 = arrow.Arrow(2013, 4, 1)
        q3 = arrow.Arrow(2013, 8, 1)
        q4 = arrow.Arrow(2013, 10, 1)
        assert q1.quarter == 1
        assert q2.quarter == 2
        assert q3.quarter == 3
        assert q4.quarter == 4

        # end dates
        q1 = arrow.Arrow(2013, 3, 31)
        q2 = arrow.Arrow(2013, 6, 30)
        q3 = arrow.Arrow(2013, 9, 30)
        q4 = arrow.Arrow(2013, 12, 31)
        assert q1.quarter == 1
        assert q2.quarter == 2
        assert q3.quarter == 3
        assert q4.quarter == 4

    def test_getattr_dt_value(self):
        assert self.arrow.year == 2013

    def test_tzinfo(self):
        assert self.arrow.tzinfo == tz.tzutc()

    def test_naive(self):
        assert self.arrow.naive == self.arrow._datetime.replace(tzinfo=None)

    def test_timestamp(self):
        assert self.arrow.timestamp() == self.arrow._datetime.timestamp()

    def test_int_timestamp(self):
        assert self.arrow.int_timestamp == int(self.arrow._datetime.timestamp())

    def test_float_timestamp(self):
        assert self.arrow.float_timestamp == self.arrow._datetime.timestamp()

    def test_getattr_fold(self):
        # UTC is always unambiguous
        assert self.now.fold == 0

        ambiguous_dt = arrow.Arrow(
            2017, 10, 29, 2, 0, tzinfo="Europe/Stockholm", fold=1
        )
        assert ambiguous_dt.fold == 1

        with pytest.raises(AttributeError):
            ambiguous_dt.fold = 0

    def test_getattr_ambiguous(self):
        assert not self.now.ambiguous

        ambiguous_dt = arrow.Arrow(2017, 10, 29, 2, 0, tzinfo="Europe/Stockholm")

        assert ambiguous_dt.ambiguous

    def test_getattr_imaginary(self):
        assert not self.now.imaginary

        imaginary_dt = arrow.Arrow(2013, 3, 31, 2, 30, tzinfo="Europe/Paris")

        assert imaginary_dt.imaginary


@pytest.mark.usefixtures("time_utcnow")
class TestArrowComparison:
    def test_eq(self):
        assert self.arrow == self.arrow
        assert self.arrow == self.arrow.datetime
        assert not (self.arrow == "abc")

    def test_ne(self):
        assert not (self.arrow != self.arrow)
        assert not (self.arrow != self.arrow.datetime)
        assert self.arrow != "abc"

    def test_gt(self):
        arrow_cmp = self.arrow.shift(minutes=1)

        assert not (self.arrow > self.arrow)
        assert not (self.arrow > self.arrow.datetime)

        with pytest.raises(TypeError):
            self.arrow > "abc"  # noqa: B015

        assert self.arrow < arrow_cmp
        assert self.arrow < arrow_cmp.datetime

    def test_ge(self):
        with pytest.raises(TypeError):
            self.arrow >= "abc"  # noqa: B015

        assert self.arrow >= self.arrow
        assert self.arrow >= self.arrow.datetime

    def test_lt(self):
        arrow_cmp = self.arrow.shift(minutes=1)

        assert not (self.arrow < self.arrow)
        assert not (self.arrow < self.arrow.datetime)

        with pytest.raises(TypeError):
            self.arrow < "abc"  # noqa: B015

        assert self.arrow < arrow_cmp
        assert self.arrow < arrow_cmp.datetime

    def test_le(self):
        with pytest.raises(TypeError):
            self.arrow <= "abc"  # noqa: B015

        assert self.arrow <= self.arrow
        assert self.arrow <= self.arrow.datetime


@pytest.mark.usefixtures("time_2013_01_01")
class TestArrowMath:
    def test_add_timedelta(self):
        result = self.arrow.__add__(timedelta(days=1))

        assert result._datetime == datetime(2013, 1, 2, tzinfo=tz.tzutc())

    def test_add_other(self):
        with pytest.raises(TypeError):
            self.arrow + 1

    def test_radd(self):
        result = self.arrow.__radd__(timedelta(days=1))

        assert result._datetime == datetime(2013, 1, 2, tzinfo=tz.tzutc())

    def test_sub_timedelta(self):
        result = self.arrow.__sub__(timedelta(days=1))

        assert result._datetime == datetime(2012, 12, 31, tzinfo=tz.tzutc())

    def test_sub_datetime(self):
        result = self.arrow.__sub__(datetime(2012, 12, 21, tzinfo=tz.tzutc()))

        assert result == timedelta(days=11)

    def test_sub_arrow(self):
        result = self.arrow.__sub__(arrow.Arrow(2012, 12, 21, tzinfo=tz.tzutc()))

        assert result == timedelta(days=11)

    def test_sub_other(self):
        with pytest.raises(TypeError):
            self.arrow - object()

    def test_rsub_datetime(self):
        result = self.arrow.__rsub__(datetime(2012, 12, 21, tzinfo=tz.tzutc()))

        assert result == timedelta(days=-11)

    def test_rsub_other(self):
        with pytest.raises(TypeError):
            timedelta(days=1) - self.arrow


@pytest.mark.usefixtures("time_utcnow")
class TestArrowDatetimeInterface:
    def test_date(self):
        result = self.arrow.date()

        assert result == self.arrow._datetime.date()

    def test_time(self):
        result = self.arrow.time()

        assert result == self.arrow._datetime.time()

    def test_timetz(self):
        result = self.arrow.timetz()

        assert result == self.arrow._datetime.timetz()

    def test_astimezone(self):
        other_tz = tz.gettz("US/Pacific")

        result = self.arrow.astimezone(other_tz)

        assert result == self.arrow._datetime.astimezone(other_tz)

    def test_utcoffset(self):
        result = self.arrow.utcoffset()

        assert result == self.arrow._datetime.utcoffset()

    def test_dst(self):
        result = self.arrow.dst()

        assert result == self.arrow._datetime.dst()

    def test_timetuple(self):
        result = self.arrow.timetuple()

        assert result == self.arrow._datetime.timetuple()

    def test_utctimetuple(self):
        result = self.arrow.utctimetuple()

        assert result == self.arrow._datetime.utctimetuple()

    def test_toordinal(self):
        result = self.arrow.toordinal()

        assert result == self.arrow._datetime.toordinal()

    def test_weekday(self):
        result = self.arrow.weekday()

        assert result == self.arrow._datetime.weekday()

    def test_isoweekday(self):
        result = self.arrow.isoweekday()

        assert result == self.arrow._datetime.isoweekday()

    def test_isocalendar(self):
        result = self.arrow.isocalendar()

        assert result == self.arrow._datetime.isocalendar()

    def test_isoformat(self):
        result = self.arrow.isoformat()

        assert result == self.arrow._datetime.isoformat()

    def test_isoformat_timespec(self):
        result = self.arrow.isoformat(timespec="hours")
        assert result == self.arrow._datetime.isoformat(timespec="hours")

        result = self.arrow.isoformat(timespec="microseconds")
        assert result == self.arrow._datetime.isoformat()

        result = self.arrow.isoformat(timespec="milliseconds")
        assert result == self.arrow._datetime.isoformat(timespec="milliseconds")

        result = self.arrow.isoformat(sep="x", timespec="seconds")
        assert result == self.arrow._datetime.isoformat(sep="x", timespec="seconds")

    def test_simplejson(self):
        result = json.dumps({"v": self.arrow.for_json()}, for_json=True)

        assert json.loads(result)["v"] == self.arrow._datetime.isoformat()

    def test_ctime(self):
        result = self.arrow.ctime()

        assert result == self.arrow._datetime.ctime()

    def test_strftime(self):
        result = self.arrow.strftime("%Y")

        assert result == self.arrow._datetime.strftime("%Y")


class TestArrowFalsePositiveDst:
    """These tests relate to issues #376 and #551.
    The key points in both issues are that arrow will assign a UTC timezone if none is provided and
    .to() will change other attributes to be correct whereas .replace() only changes the specified attribute.

    Issue 376
    >>> arrow.get('2016-11-06').to('America/New_York').ceil('day')
    < Arrow [2016-11-05T23:59:59.999999-04:00] >

    Issue 551
    >>> just_before = arrow.get('2018-11-04T01:59:59.999999')
    >>> just_before
    2018-11-04T01:59:59.999999+00:00
    >>> just_after = just_before.shift(microseconds=1)
    >>> just_after
    2018-11-04T02:00:00+00:00
    >>> just_before_eastern = just_before.replace(tzinfo='US/Eastern')
    >>> just_before_eastern
    2018-11-04T01:59:59.999999-04:00
    >>> just_after_eastern = just_after.replace(tzinfo='US/Eastern')
    >>> just_after_eastern
    2018-11-04T02:00:00-05:00
    """

    def test_dst(self):
        self.before_1 = arrow.Arrow(
            2016, 11, 6, 3, 59, tzinfo=tz.gettz("America/New_York")
        )
        self.before_2 = arrow.Arrow(2016, 11, 6, tzinfo=tz.gettz("America/New_York"))
        self.after_1 = arrow.Arrow(2016, 11, 6, 4, tzinfo=tz.gettz("America/New_York"))
        self.after_2 = arrow.Arrow(
            2016, 11, 6, 23, 59, tzinfo=tz.gettz("America/New_York")
        )
        self.before_3 = arrow.Arrow(
            2018, 11, 4, 3, 59, tzinfo=tz.gettz("America/New_York")
        )
        self.before_4 = arrow.Arrow(2018, 11, 4, tzinfo=tz.gettz("America/New_York"))
        self.after_3 = arrow.Arrow(2018, 11, 4, 4, tzinfo=tz.gettz("America/New_York"))
        self.after_4 = arrow.Arrow(
            2018, 11, 4, 23, 59, tzinfo=tz.gettz("America/New_York")
        )
        assert self.before_1.day == self.before_2.day
        assert self.after_1.day == self.after_2.day
        assert self.before_3.day == self.before_4.day
        assert self.after_3.day == self.after_4.day


class TestArrowConversion:
    def test_to(self):
        dt_from = datetime.now()
        arrow_from = arrow.Arrow.fromdatetime(dt_from, tz.gettz("US/Pacific"))

        self.expected = dt_from.replace(tzinfo=tz.gettz("US/Pacific")).astimezone(
            tz.tzutc()
        )

        assert arrow_from.to("UTC").datetime == self.expected
        assert arrow_from.to(tz.tzutc()).datetime == self.expected

    # issue #368
    def test_to_pacific_then_utc(self):
        result = arrow.Arrow(2018, 11, 4, 1, tzinfo="-08:00").to("US/Pacific").to("UTC")
        assert result == arrow.Arrow(2018, 11, 4, 9)

    # issue #368
    def test_to_amsterdam_then_utc(self):
        result = arrow.Arrow(2016, 10, 30).to("Europe/Amsterdam")
        assert result.utcoffset() == timedelta(seconds=7200)

    # regression test for #690
    def test_to_israel_same_offset(self):
        result = arrow.Arrow(2019, 10, 27, 2, 21, 1, tzinfo="+03:00").to("Israel")
        expected = arrow.Arrow(2019, 10, 27, 1, 21, 1, tzinfo="Israel")

        assert result == expected
        assert result.utcoffset() != expected.utcoffset()

    # issue 315
    def test_anchorage_dst(self):
        before = arrow.Arrow(2016, 3, 13, 1, 59, tzinfo="America/Anchorage")
        after = arrow.Arrow(2016, 3, 13, 2, 1, tzinfo="America/Anchorage")

        assert before.utcoffset() != after.utcoffset()

    # issue 476
    def test_chicago_fall(self):
        result = arrow.Arrow(2017, 11, 5, 2, 1, tzinfo="-05:00").to("America/Chicago")
        expected = arrow.Arrow(2017, 11, 5, 1, 1, tzinfo="America/Chicago")

        assert result == expected
        assert result.utcoffset() != expected.utcoffset()

    def test_toronto_gap(self):
        before = arrow.Arrow(2011, 3, 13, 6, 30, tzinfo="UTC").to("America/Toronto")
        after = arrow.Arrow(2011, 3, 13, 7, 30, tzinfo="UTC").to("America/Toronto")

        assert before.datetime.replace(tzinfo=None) == datetime(2011, 3, 13, 1, 30)
        assert after.datetime.replace(tzinfo=None) == datetime(2011, 3, 13, 3, 30)

        assert before.utcoffset() != after.utcoffset()

    def test_sydney_gap(self):
        before = arrow.Arrow(2012, 10, 6, 15, 30, tzinfo="UTC").to("Australia/Sydney")
        after = arrow.Arrow(2012, 10, 6, 16, 30, tzinfo="UTC").to("Australia/Sydney")

        assert before.datetime.replace(tzinfo=None) == datetime(2012, 10, 7, 1, 30)
        assert after.datetime.replace(tzinfo=None) == datetime(2012, 10, 7, 3, 30)

        assert before.utcoffset() != after.utcoffset()


class TestArrowPickling:
    def test_pickle_and_unpickle(self):
        dt = arrow.Arrow.utcnow()

        pickled = pickle.dumps(dt)

        unpickled = pickle.loads(pickled)

        assert unpickled == dt


class TestArrowReplace:
    def test_not_attr(self):
        with pytest.raises(ValueError):
            arrow.Arrow.utcnow().replace(abc=1)

    def test_replace(self):
        arw = arrow.Arrow(2013, 5, 5, 12, 30, 45)

        assert arw.replace(year=2012) == arrow.Arrow(2012, 5, 5, 12, 30, 45)
        assert arw.replace(month=1) == arrow.Arrow(2013, 1, 5, 12, 30, 45)
        assert arw.replace(day=1) == arrow.Arrow(2013, 5, 1, 12, 30, 45)
        assert arw.replace(hour=1) == arrow.Arrow(2013, 5, 5, 1, 30, 45)
        assert arw.replace(minute=1) == arrow.Arrow(2013, 5, 5, 12, 1, 45)
        assert arw.replace(second=1) == arrow.Arrow(2013, 5, 5, 12, 30, 1)

    def test_replace_tzinfo(self):
        arw = arrow.Arrow.utcnow().to("US/Eastern")

        result = arw.replace(tzinfo=tz.gettz("US/Pacific"))

        assert result == arw.datetime.replace(tzinfo=tz.gettz("US/Pacific"))

    def test_replace_fold(self):
        before = arrow.Arrow(2017, 11, 5, 1, tzinfo="America/New_York")
        after = before.replace(fold=1)

        assert before.fold == 0
        assert after.fold == 1
        assert before == after
        assert before.utcoffset() != after.utcoffset()

    def test_replace_fold_and_other(self):
        arw = arrow.Arrow(2013, 5, 5, 12, 30, 45)

        assert arw.replace(fold=1, minute=50) == arrow.Arrow(2013, 5, 5, 12, 50, 45)
        assert arw.replace(minute=50, fold=1) == arrow.Arrow(2013, 5, 5, 12, 50, 45)

    def test_replace_week(self):
        with pytest.raises(ValueError):
            arrow.Arrow.utcnow().replace(week=1)

    def test_replace_quarter(self):
        with pytest.raises(ValueError):
            arrow.Arrow.utcnow().replace(quarter=1)

    def test_replace_quarter_and_fold(self):
        with pytest.raises(AttributeError):
            arrow.utcnow().replace(fold=1, quarter=1)

        with pytest.raises(AttributeError):
            arrow.utcnow().replace(quarter=1, fold=1)

    def test_replace_other_kwargs(self):
        with pytest.raises(AttributeError):
            arrow.utcnow().replace(abc="def")


class TestArrowShift:
    def test_not_attr(self):
        now = arrow.Arrow.utcnow()

        with pytest.raises(ValueError):
            now.shift(abc=1)

        with pytest.raises(ValueError):
            now.shift(week=1)

    def test_shift(self):
        arw = arrow.Arrow(2013, 5, 5, 12, 30, 45)

        assert arw.shift(years=1) == arrow.Arrow(2014, 5, 5, 12, 30, 45)
        assert arw.shift(quarters=1) == arrow.Arrow(2013, 8, 5, 12, 30, 45)
        assert arw.shift(quarters=1, months=1) == arrow.Arrow(2013, 9, 5, 12, 30, 45)
        assert arw.shift(months=1) == arrow.Arrow(2013, 6, 5, 12, 30, 45)
        assert arw.shift(weeks=1) == arrow.Arrow(2013, 5, 12, 12, 30, 45)
        assert arw.shift(days=1) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(hours=1) == arrow.Arrow(2013, 5, 5, 13, 30, 45)
        assert arw.shift(minutes=1) == arrow.Arrow(2013, 5, 5, 12, 31, 45)
        assert arw.shift(seconds=1) == arrow.Arrow(2013, 5, 5, 12, 30, 46)
        assert arw.shift(microseconds=1) == arrow.Arrow(2013, 5, 5, 12, 30, 45, 1)

        # Remember: Python's weekday 0 is Monday
        assert arw.shift(weekday=0) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(weekday=1) == arrow.Arrow(2013, 5, 7, 12, 30, 45)
        assert arw.shift(weekday=2) == arrow.Arrow(2013, 5, 8, 12, 30, 45)
        assert arw.shift(weekday=3) == arrow.Arrow(2013, 5, 9, 12, 30, 45)
        assert arw.shift(weekday=4) == arrow.Arrow(2013, 5, 10, 12, 30, 45)
        assert arw.shift(weekday=5) == arrow.Arrow(2013, 5, 11, 12, 30, 45)
        assert arw.shift(weekday=6) == arw

        with pytest.raises(IndexError):
            arw.shift(weekday=7)

        # Use dateutil.relativedelta's convenient day instances
        assert arw.shift(weekday=MO) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(weekday=MO(0)) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(weekday=MO(1)) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(weekday=MO(2)) == arrow.Arrow(2013, 5, 13, 12, 30, 45)
        assert arw.shift(weekday=TU) == arrow.Arrow(2013, 5, 7, 12, 30, 45)
        assert arw.shift(weekday=TU(0)) == arrow.Arrow(2013, 5, 7, 12, 30, 45)
        assert arw.shift(weekday=TU(1)) == arrow.Arrow(2013, 5, 7, 12, 30, 45)
        assert arw.shift(weekday=TU(2)) == arrow.Arrow(2013, 5, 14, 12, 30, 45)
        assert arw.shift(weekday=WE) == arrow.Arrow(2013, 5, 8, 12, 30, 45)
        assert arw.shift(weekday=WE(0)) == arrow.Arrow(2013, 5, 8, 12, 30, 45)
        assert arw.shift(weekday=WE(1)) == arrow.Arrow(2013, 5, 8, 12, 30, 45)
        assert arw.shift(weekday=WE(2)) == arrow.Arrow(2013, 5, 15, 12, 30, 45)
        assert arw.shift(weekday=TH) == arrow.Arrow(2013, 5, 9, 12, 30, 45)
        assert arw.shift(weekday=TH(0)) == arrow.Arrow(2013, 5, 9, 12, 30, 45)
        assert arw.shift(weekday=TH(1)) == arrow.Arrow(2013, 5, 9, 12, 30, 45)
        assert arw.shift(weekday=TH(2)) == arrow.Arrow(2013, 5, 16, 12, 30, 45)
        assert arw.shift(weekday=FR) == arrow.Arrow(2013, 5, 10, 12, 30, 45)
        assert arw.shift(weekday=FR(0)) == arrow.Arrow(2013, 5, 10, 12, 30, 45)
        assert arw.shift(weekday=FR(1)) == arrow.Arrow(2013, 5, 10, 12, 30, 45)
        assert arw.shift(weekday=FR(2)) == arrow.Arrow(2013, 5, 17, 12, 30, 45)
        assert arw.shift(weekday=SA) == arrow.Arrow(2013, 5, 11, 12, 30, 45)
        assert arw.shift(weekday=SA(0)) == arrow.Arrow(2013, 5, 11, 12, 30, 45)
        assert arw.shift(weekday=SA(1)) == arrow.Arrow(2013, 5, 11, 12, 30, 45)
        assert arw.shift(weekday=SA(2)) == arrow.Arrow(2013, 5, 18, 12, 30, 45)
        assert arw.shift(weekday=SU) == arw
        assert arw.shift(weekday=SU(0)) == arw
        assert arw.shift(weekday=SU(1)) == arw
        assert arw.shift(weekday=SU(2)) == arrow.Arrow(2013, 5, 12, 12, 30, 45)

    def test_shift_negative(self):
        arw = arrow.Arrow(2013, 5, 5, 12, 30, 45)

        assert arw.shift(years=-1) == arrow.Arrow(2012, 5, 5, 12, 30, 45)
        assert arw.shift(quarters=-1) == arrow.Arrow(2013, 2, 5, 12, 30, 45)
        assert arw.shift(quarters=-1, months=-1) == arrow.Arrow(2013, 1, 5, 12, 30, 45)
        assert arw.shift(months=-1) == arrow.Arrow(2013, 4, 5, 12, 30, 45)
        assert arw.shift(weeks=-1) == arrow.Arrow(2013, 4, 28, 12, 30, 45)
        assert arw.shift(days=-1) == arrow.Arrow(2013, 5, 4, 12, 30, 45)
        assert arw.shift(hours=-1) == arrow.Arrow(2013, 5, 5, 11, 30, 45)
        assert arw.shift(minutes=-1) == arrow.Arrow(2013, 5, 5, 12, 29, 45)
        assert arw.shift(seconds=-1) == arrow.Arrow(2013, 5, 5, 12, 30, 44)
        assert arw.shift(microseconds=-1) == arrow.Arrow(2013, 5, 5, 12, 30, 44, 999999)

        # Not sure how practical these negative weekdays are
        assert arw.shift(weekday=-1) == arw.shift(weekday=SU)
        assert arw.shift(weekday=-2) == arw.shift(weekday=SA)
        assert arw.shift(weekday=-3) == arw.shift(weekday=FR)
        assert arw.shift(weekday=-4) == arw.shift(weekday=TH)
        assert arw.shift(weekday=-5) == arw.shift(weekday=WE)
        assert arw.shift(weekday=-6) == arw.shift(weekday=TU)
        assert arw.shift(weekday=-7) == arw.shift(weekday=MO)

        with pytest.raises(IndexError):
            arw.shift(weekday=-8)

        assert arw.shift(weekday=MO(-1)) == arrow.Arrow(2013, 4, 29, 12, 30, 45)
        assert arw.shift(weekday=TU(-1)) == arrow.Arrow(2013, 4, 30, 12, 30, 45)
        assert arw.shift(weekday=WE(-1)) == arrow.Arrow(2013, 5, 1, 12, 30, 45)
        assert arw.shift(weekday=TH(-1)) == arrow.Arrow(2013, 5, 2, 12, 30, 45)
        assert arw.shift(weekday=FR(-1)) == arrow.Arrow(2013, 5, 3, 12, 30, 45)
        assert arw.shift(weekday=SA(-1)) == arrow.Arrow(2013, 5, 4, 12, 30, 45)
        assert arw.shift(weekday=SU(-1)) == arw
        assert arw.shift(weekday=SU(-2)) == arrow.Arrow(2013, 4, 28, 12, 30, 45)

    def test_shift_quarters_bug(self):
        arw = arrow.Arrow(2013, 5, 5, 12, 30, 45)

        # The value of the last-read argument was used instead of the ``quarters`` argument.
        # Recall that the keyword argument dict, like all dicts, is unordered, so only certain
        # combinations of arguments would exhibit this.
        assert arw.shift(quarters=0, years=1) == arrow.Arrow(2014, 5, 5, 12, 30, 45)
        assert arw.shift(quarters=0, months=1) == arrow.Arrow(2013, 6, 5, 12, 30, 45)
        assert arw.shift(quarters=0, weeks=1) == arrow.Arrow(2013, 5, 12, 12, 30, 45)
        assert arw.shift(quarters=0, days=1) == arrow.Arrow(2013, 5, 6, 12, 30, 45)
        assert arw.shift(quarters=0, hours=1) == arrow.Arrow(2013, 5, 5, 13, 30, 45)
        assert arw.shift(quarters=0, minutes=1) == arrow.Arrow(2013, 5, 5, 12, 31, 45)
        assert arw.shift(quarters=0, seconds=1) == arrow.Arrow(2013, 5, 5, 12, 30, 46)
        assert arw.shift(quarters=0, microseconds=1) == arrow.Arrow(
            2013, 5, 5, 12, 30, 45, 1
        )

    def test_shift_positive_imaginary(self):
        # Avoid shifting into imaginary datetimes, take into account DST and other timezone changes.

        new_york = arrow.Arrow(2017, 3, 12, 1, 30, tzinfo="America/New_York")
        assert new_york.shift(hours=+1) == arrow.Arrow(
            2017, 3, 12, 3, 30, tzinfo="America/New_York"
        )

        # pendulum example
        paris = arrow.Arrow(2013, 3, 31, 1, 50, tzinfo="Europe/Paris")
        assert paris.shift(minutes=+20) == arrow.Arrow(
            2013, 3, 31, 3, 10, tzinfo="Europe/Paris"
        )

        canberra = arrow.Arrow(2018, 10, 7, 1, 30, tzinfo="Australia/Canberra")
        assert canberra.shift(hours=+1) == arrow.Arrow(
            2018, 10, 7, 3, 30, tzinfo="Australia/Canberra"
        )

        kiev = arrow.Arrow(2018, 3, 25, 2, 30, tzinfo="Europe/Kiev")
        assert kiev.shift(hours=+1) == arrow.Arrow(
            2018, 3, 25, 4, 30, tzinfo="Europe/Kiev"
        )

        # Edge case, the entire day of 2011-12-30 is imaginary in this zone!
        apia = arrow.Arrow(2011, 12, 29, 23, tzinfo="Pacific/Apia")
        assert apia.shift(hours=+2) == arrow.Arrow(
            2011, 12, 31, 1, tzinfo="Pacific/Apia"
        )

    def test_shift_negative_imaginary(self):
        new_york = arrow.Arrow(2011, 3, 13, 3, 30, tzinfo="America/New_York")
        assert new_york.shift(hours=-1) == arrow.Arrow(
            2011, 3, 13, 3, 30, tzinfo="America/New_York"
        )
        assert new_york.shift(hours=-2) == arrow.Arrow(
            2011, 3, 13, 1, 30, tzinfo="America/New_York"
        )

        london = arrow.Arrow(2019, 3, 31, 2, tzinfo="Europe/London")
        assert london.shift(hours=-1) == arrow.Arrow(
            2019, 3, 31, 2, tzinfo="Europe/London"
        )
        assert london.shift(hours=-2) == arrow.Arrow(
            2019, 3, 31, 0, tzinfo="Europe/London"
        )

        # edge case, crossing the international dateline
        apia = arrow.Arrow(2011, 12, 31, 1, tzinfo="Pacific/Apia")
        assert apia.shift(hours=-2) == arrow.Arrow(
            2011, 12, 31, 23, tzinfo="Pacific/Apia"
        )

    @pytest.mark.skipif(
        dateutil.__version__ < "2.7.1", reason="old tz database (2018d needed)"
    )
    def test_shift_kiritimati(self):
        # corrected 2018d tz database release, will fail in earlier versions

        kiritimati = arrow.Arrow(1994, 12, 30, 12, 30, tzinfo="Pacific/Kiritimati")
        assert kiritimati.shift(days=+1) == arrow.Arrow(
            1995, 1, 1, 12, 30, tzinfo="Pacific/Kiritimati"
        )

    def shift_imaginary_seconds(self):
        # offset has a seconds component
        monrovia = arrow.Arrow(1972, 1, 6, 23, tzinfo="Africa/Monrovia")
        assert monrovia.shift(hours=+1, minutes=+30) == arrow.Arrow(
            1972, 1, 7, 1, 14, 30, tzinfo="Africa/Monrovia"
        )


class TestArrowRange:
    def test_year(self):
        result = list(
            arrow.Arrow.range(
                "year", datetime(2013, 1, 2, 3, 4, 5), datetime(2016, 4, 5, 6, 7, 8)
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2014, 1, 2, 3, 4, 5),
            arrow.Arrow(2015, 1, 2, 3, 4, 5),
            arrow.Arrow(2016, 1, 2, 3, 4, 5),
        ]

    def test_quarter(self):
        result = list(
            arrow.Arrow.range(
                "quarter", datetime(2013, 2, 3, 4, 5, 6), datetime(2013, 5, 6, 7, 8, 9)
            )
        )

        assert result == [
            arrow.Arrow(2013, 2, 3, 4, 5, 6),
            arrow.Arrow(2013, 5, 3, 4, 5, 6),
        ]

    def test_month(self):
        result = list(
            arrow.Arrow.range(
                "month", datetime(2013, 2, 3, 4, 5, 6), datetime(2013, 5, 6, 7, 8, 9)
            )
        )

        assert result == [
            arrow.Arrow(2013, 2, 3, 4, 5, 6),
            arrow.Arrow(2013, 3, 3, 4, 5, 6),
            arrow.Arrow(2013, 4, 3, 4, 5, 6),
            arrow.Arrow(2013, 5, 3, 4, 5, 6),
        ]

    def test_week(self):
        result = list(
            arrow.Arrow.range(
                "week", datetime(2013, 9, 1, 2, 3, 4), datetime(2013, 10, 1, 2, 3, 4)
            )
        )

        assert result == [
            arrow.Arrow(2013, 9, 1, 2, 3, 4),
            arrow.Arrow(2013, 9, 8, 2, 3, 4),
            arrow.Arrow(2013, 9, 15, 2, 3, 4),
            arrow.Arrow(2013, 9, 22, 2, 3, 4),
            arrow.Arrow(2013, 9, 29, 2, 3, 4),
        ]

    def test_day(self):
        result = list(
            arrow.Arrow.range(
                "day", datetime(2013, 1, 2, 3, 4, 5), datetime(2013, 1, 5, 6, 7, 8)
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2013, 1, 3, 3, 4, 5),
            arrow.Arrow(2013, 1, 4, 3, 4, 5),
            arrow.Arrow(2013, 1, 5, 3, 4, 5),
        ]

    def test_hour(self):
        result = list(
            arrow.Arrow.range(
                "hour", datetime(2013, 1, 2, 3, 4, 5), datetime(2013, 1, 2, 6, 7, 8)
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2013, 1, 2, 4, 4, 5),
            arrow.Arrow(2013, 1, 2, 5, 4, 5),
            arrow.Arrow(2013, 1, 2, 6, 4, 5),
        ]

        result = list(
            arrow.Arrow.range(
                "hour", datetime(2013, 1, 2, 3, 4, 5), datetime(2013, 1, 2, 3, 4, 5)
            )
        )

        assert result == [arrow.Arrow(2013, 1, 2, 3, 4, 5)]

    def test_minute(self):
        result = list(
            arrow.Arrow.range(
                "minute", datetime(2013, 1, 2, 3, 4, 5), datetime(2013, 1, 2, 3, 7, 8)
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2013, 1, 2, 3, 5, 5),
            arrow.Arrow(2013, 1, 2, 3, 6, 5),
            arrow.Arrow(2013, 1, 2, 3, 7, 5),
        ]

    def test_second(self):
        result = list(
            arrow.Arrow.range(
                "second", datetime(2013, 1, 2, 3, 4, 5), datetime(2013, 1, 2, 3, 4, 8)
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2013, 1, 2, 3, 4, 6),
            arrow.Arrow(2013, 1, 2, 3, 4, 7),
            arrow.Arrow(2013, 1, 2, 3, 4, 8),
        ]

    def test_arrow(self):
        result = list(
            arrow.Arrow.range(
                "day",
                arrow.Arrow(2013, 1, 2, 3, 4, 5),
                arrow.Arrow(2013, 1, 5, 6, 7, 8),
            )
        )

        assert result == [
            arrow.Arrow(2013, 1, 2, 3, 4, 5),
            arrow.Arrow(2013, 1, 3, 3, 4, 5),
            arrow.Arrow(2013, 1, 4, 3, 4, 5),
            arrow.Arrow(2013, 1, 5, 3, 4, 5),
        ]

    def test_naive_tz(self):
        result = arrow.Arrow.range(
            "year", datetime(2013, 1, 2, 3), datetime(2016, 4, 5, 6), "US/Pacific"
        )

        for r in result:
            assert r.tzinfo == tz.gettz("US/Pacific")

    def test_aware_same_tz(self):
        result = arrow.Arrow.range(
            "day",
            arrow.Arrow(2013, 1, 1, tzinfo=tz.gettz("US/Pacific")),
            arrow.Arrow(2013, 1, 3, tzinfo=tz.gettz("US/Pacific")),
        )

        for r in result:
            assert r.tzinfo == tz.gettz("US/Pacific")

    def test_aware_different_tz(self):
        result = arrow.Arrow.range(
            "day",
            datetime(2013, 1, 1, tzinfo=tz.gettz("US/Eastern")),
            datetime(2013, 1, 3, tzinfo=tz.gettz("US/Pacific")),
        )

        for r in result:
            assert r.tzinfo == tz.gettz("US/Eastern")

    def test_aware_tz(self):
        result = arrow.Arrow.range(
            "day",
            datetime(2013, 1, 1, tzinfo=tz.gettz("US/Eastern")),
            datetime(2013, 1, 3, tzinfo=tz.gettz("US/Pacific")),
            tz=tz.gettz("US/Central"),
        )

        for r in result:
            assert r.tzinfo == tz.gettz("US/Central")

    def test_imaginary(self):
        # issue #72, avoid duplication in utc column

        before = arrow.Arrow(2018, 3, 10, 23, tzinfo="US/Pacific")
        after = arrow.Arrow(2018, 3, 11, 4, tzinfo="US/Pacific")

        pacific_range = [t for t in arrow.Arrow.range("hour", before, after)]
        utc_range = [t.to("utc") for t in arrow.Arrow.range("hour", before, after)]

        assert len(pacific_range) == len(set(pacific_range))
        assert len(utc_range) == len(set(utc_range))

    def test_unsupported(self):
        with pytest.raises(ValueError):
            next(arrow.Arrow.range("abc", datetime.utcnow(), datetime.utcnow()))

    def test_range_over_months_ending_on_different_days(self):
        # regression test for issue #842
        result = list(arrow.Arrow.range("month", datetime(2015, 1, 31), limit=4))
        assert result == [
            arrow.Arrow(2015, 1, 31),
            arrow.Arrow(2015, 2, 28),
            arrow.Arrow(2015, 3, 31),
            arrow.Arrow(2015, 4, 30),
        ]

        result = list(arrow.Arrow.range("month", datetime(2015, 1, 30), limit=3))
        assert result == [
            arrow.Arrow(2015, 1, 30),
            arrow.Arrow(2015, 2, 28),
            arrow.Arrow(2015, 3, 30),
        ]

        result = list(arrow.Arrow.range("month", datetime(2015, 2, 28), limit=3))
        assert result == [
            arrow.Arrow(2015, 2, 28),
            arrow.Arrow(2015, 3, 28),
            arrow.Arrow(2015, 4, 28),
        ]

        result = list(arrow.Arrow.range("month", datetime(2015, 3, 31), limit=3))
        assert result == [
            arrow.Arrow(2015, 3, 31),
            arrow.Arrow(2015, 4, 30),
            arrow.Arrow(2015, 5, 31),
        ]

    def test_range_over_quarter_months_ending_on_different_days(self):
        result = list(arrow.Arrow.range("quarter", datetime(2014, 11, 30), limit=3))
        assert result == [
            arrow.Arrow(2014, 11, 30),
            arrow.Arrow(2015, 2, 28),
            arrow.Arrow(2015, 5, 30),
        ]

    def test_range_over_year_maintains_end_date_across_leap_year(self):
        result = list(arrow.Arrow.range("year", datetime(2012, 2, 29), limit=5))
        assert result == [
            arrow.Arrow(2012, 2, 29),
            arrow.Arrow(2013, 2, 28),
            arrow.Arrow(2014, 2, 28),
            arrow.Arrow(2015, 2, 28),
            arrow.Arrow(2016, 2, 29),
        ]


class TestArrowSpanRange:
    def test_year(self):
        result = list(
            arrow.Arrow.span_range("year", datetime(2013, 2, 1), datetime(2016, 3, 31))
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1),
                arrow.Arrow(2013, 12, 31, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2014, 1, 1),
                arrow.Arrow(2014, 12, 31, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2015, 1, 1),
                arrow.Arrow(2015, 12, 31, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2016, 1, 1),
                arrow.Arrow(2016, 12, 31, 23, 59, 59, 999999),
            ),
        ]

    def test_quarter(self):
        result = list(
            arrow.Arrow.span_range(
                "quarter", datetime(2013, 2, 2), datetime(2013, 5, 15)
            )
        )

        assert result == [
            (arrow.Arrow(2013, 1, 1), arrow.Arrow(2013, 3, 31, 23, 59, 59, 999999)),
            (arrow.Arrow(2013, 4, 1), arrow.Arrow(2013, 6, 30, 23, 59, 59, 999999)),
        ]

    def test_month(self):
        result = list(
            arrow.Arrow.span_range("month", datetime(2013, 1, 2), datetime(2013, 4, 15))
        )

        assert result == [
            (arrow.Arrow(2013, 1, 1), arrow.Arrow(2013, 1, 31, 23, 59, 59, 999999)),
            (arrow.Arrow(2013, 2, 1), arrow.Arrow(2013, 2, 28, 23, 59, 59, 999999)),
            (arrow.Arrow(2013, 3, 1), arrow.Arrow(2013, 3, 31, 23, 59, 59, 999999)),
            (arrow.Arrow(2013, 4, 1), arrow.Arrow(2013, 4, 30, 23, 59, 59, 999999)),
        ]

    def test_week(self):
        result = list(
            arrow.Arrow.span_range("week", datetime(2013, 2, 2), datetime(2013, 2, 28))
        )

        assert result == [
            (arrow.Arrow(2013, 1, 28), arrow.Arrow(2013, 2, 3, 23, 59, 59, 999999)),
            (arrow.Arrow(2013, 2, 4), arrow.Arrow(2013, 2, 10, 23, 59, 59, 999999)),
            (
                arrow.Arrow(2013, 2, 11),
                arrow.Arrow(2013, 2, 17, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 2, 18),
                arrow.Arrow(2013, 2, 24, 23, 59, 59, 999999),
            ),
            (arrow.Arrow(2013, 2, 25), arrow.Arrow(2013, 3, 3, 23, 59, 59, 999999)),
        ]

    def test_day(self):
        result = list(
            arrow.Arrow.span_range(
                "day", datetime(2013, 1, 1, 12), datetime(2013, 1, 4, 12)
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1, 0),
                arrow.Arrow(2013, 1, 1, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 2, 0),
                arrow.Arrow(2013, 1, 2, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 3, 0),
                arrow.Arrow(2013, 1, 3, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 4, 0),
                arrow.Arrow(2013, 1, 4, 23, 59, 59, 999999),
            ),
        ]

    def test_days(self):
        result = list(
            arrow.Arrow.span_range(
                "days", datetime(2013, 1, 1, 12), datetime(2013, 1, 4, 12)
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1, 0),
                arrow.Arrow(2013, 1, 1, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 2, 0),
                arrow.Arrow(2013, 1, 2, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 3, 0),
                arrow.Arrow(2013, 1, 3, 23, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 4, 0),
                arrow.Arrow(2013, 1, 4, 23, 59, 59, 999999),
            ),
        ]

    def test_hour(self):
        result = list(
            arrow.Arrow.span_range(
                "hour", datetime(2013, 1, 1, 0, 30), datetime(2013, 1, 1, 3, 30)
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1, 0),
                arrow.Arrow(2013, 1, 1, 0, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 1),
                arrow.Arrow(2013, 1, 1, 1, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 2),
                arrow.Arrow(2013, 1, 1, 2, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 3),
                arrow.Arrow(2013, 1, 1, 3, 59, 59, 999999),
            ),
        ]

        result = list(
            arrow.Arrow.span_range(
                "hour", datetime(2013, 1, 1, 3, 30), datetime(2013, 1, 1, 3, 30)
            )
        )

        assert result == [
            (arrow.Arrow(2013, 1, 1, 3), arrow.Arrow(2013, 1, 1, 3, 59, 59, 999999))
        ]

    def test_minute(self):
        result = list(
            arrow.Arrow.span_range(
                "minute", datetime(2013, 1, 1, 0, 0, 30), datetime(2013, 1, 1, 0, 3, 30)
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1, 0, 0),
                arrow.Arrow(2013, 1, 1, 0, 0, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 1),
                arrow.Arrow(2013, 1, 1, 0, 1, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 2),
                arrow.Arrow(2013, 1, 1, 0, 2, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 3),
                arrow.Arrow(2013, 1, 1, 0, 3, 59, 999999),
            ),
        ]

    def test_second(self):
        result = list(
            arrow.Arrow.span_range(
                "second", datetime(2013, 1, 1), datetime(2013, 1, 1, 0, 0, 3)
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 1, 1, 0, 0, 0),
                arrow.Arrow(2013, 1, 1, 0, 0, 0, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 0, 1),
                arrow.Arrow(2013, 1, 1, 0, 0, 1, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 0, 2),
                arrow.Arrow(2013, 1, 1, 0, 0, 2, 999999),
            ),
            (
                arrow.Arrow(2013, 1, 1, 0, 0, 3),
                arrow.Arrow(2013, 1, 1, 0, 0, 3, 999999),
            ),
        ]

    def test_naive_tz(self):
        tzinfo = tz.gettz("US/Pacific")

        result = arrow.Arrow.span_range(
            "hour", datetime(2013, 1, 1, 0), datetime(2013, 1, 1, 3, 59), "US/Pacific"
        )

        for f, c in result:
            assert f.tzinfo == tzinfo
            assert c.tzinfo == tzinfo

    def test_aware_same_tz(self):
        tzinfo = tz.gettz("US/Pacific")

        result = arrow.Arrow.span_range(
            "hour",
            datetime(2013, 1, 1, 0, tzinfo=tzinfo),
            datetime(2013, 1, 1, 2, 59, tzinfo=tzinfo),
        )

        for f, c in result:
            assert f.tzinfo == tzinfo
            assert c.tzinfo == tzinfo

    def test_aware_different_tz(self):
        tzinfo1 = tz.gettz("US/Pacific")
        tzinfo2 = tz.gettz("US/Eastern")

        result = arrow.Arrow.span_range(
            "hour",
            datetime(2013, 1, 1, 0, tzinfo=tzinfo1),
            datetime(2013, 1, 1, 2, 59, tzinfo=tzinfo2),
        )

        for f, c in result:
            assert f.tzinfo == tzinfo1
            assert c.tzinfo == tzinfo1

    def test_aware_tz(self):
        result = arrow.Arrow.span_range(
            "hour",
            datetime(2013, 1, 1, 0, tzinfo=tz.gettz("US/Eastern")),
            datetime(2013, 1, 1, 2, 59, tzinfo=tz.gettz("US/Eastern")),
            tz="US/Central",
        )

        for f, c in result:
            assert f.tzinfo == tz.gettz("US/Central")
            assert c.tzinfo == tz.gettz("US/Central")

    def test_bounds_param_is_passed(self):
        result = list(
            arrow.Arrow.span_range(
                "quarter", datetime(2013, 2, 2), datetime(2013, 5, 15), bounds="[]"
            )
        )

        assert result == [
            (arrow.Arrow(2013, 1, 1), arrow.Arrow(2013, 4, 1)),
            (arrow.Arrow(2013, 4, 1), arrow.Arrow(2013, 7, 1)),
        ]

    def test_exact_bound_exclude(self):
        result = list(
            arrow.Arrow.span_range(
                "hour",
                datetime(2013, 5, 5, 12, 30),
                datetime(2013, 5, 5, 17, 15),
                bounds="[)",
                exact=True,
            )
        )

        expected = [
            (
                arrow.Arrow(2013, 5, 5, 12, 30),
                arrow.Arrow(2013, 5, 5, 13, 29, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 13, 30),
                arrow.Arrow(2013, 5, 5, 14, 29, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 14, 30),
                arrow.Arrow(2013, 5, 5, 15, 29, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 15, 30),
                arrow.Arrow(2013, 5, 5, 16, 29, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 16, 30),
                arrow.Arrow(2013, 5, 5, 17, 14, 59, 999999),
            ),
        ]

        assert result == expected

    def test_exact_floor_equals_end(self):
        result = list(
            arrow.Arrow.span_range(
                "minute",
                datetime(2013, 5, 5, 12, 30),
                datetime(2013, 5, 5, 12, 40),
                exact=True,
            )
        )

        expected = [
            (
                arrow.Arrow(2013, 5, 5, 12, 30),
                arrow.Arrow(2013, 5, 5, 12, 30, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 31),
                arrow.Arrow(2013, 5, 5, 12, 31, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 32),
                arrow.Arrow(2013, 5, 5, 12, 32, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 33),
                arrow.Arrow(2013, 5, 5, 12, 33, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 34),
                arrow.Arrow(2013, 5, 5, 12, 34, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 35),
                arrow.Arrow(2013, 5, 5, 12, 35, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 36),
                arrow.Arrow(2013, 5, 5, 12, 36, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 37),
                arrow.Arrow(2013, 5, 5, 12, 37, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 38),
                arrow.Arrow(2013, 5, 5, 12, 38, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 12, 39),
                arrow.Arrow(2013, 5, 5, 12, 39, 59, 999999),
            ),
        ]

        assert result == expected

    def test_exact_bound_include(self):
        result = list(
            arrow.Arrow.span_range(
                "hour",
                datetime(2013, 5, 5, 2, 30),
                datetime(2013, 5, 5, 6, 00),
                bounds="(]",
                exact=True,
            )
        )

        expected = [
            (
                arrow.Arrow(2013, 5, 5, 2, 30, 00, 1),
                arrow.Arrow(2013, 5, 5, 3, 30, 00, 0),
            ),
            (
                arrow.Arrow(2013, 5, 5, 3, 30, 00, 1),
                arrow.Arrow(2013, 5, 5, 4, 30, 00, 0),
            ),
            (
                arrow.Arrow(2013, 5, 5, 4, 30, 00, 1),
                arrow.Arrow(2013, 5, 5, 5, 30, 00, 0),
            ),
            (
                arrow.Arrow(2013, 5, 5, 5, 30, 00, 1),
                arrow.Arrow(2013, 5, 5, 6, 00),
            ),
        ]

        assert result == expected

    def test_small_interval_exact_open_bounds(self):
        result = list(
            arrow.Arrow.span_range(
                "minute",
                datetime(2013, 5, 5, 2, 30),
                datetime(2013, 5, 5, 2, 31),
                bounds="()",
                exact=True,
            )
        )

        expected = [
            (
                arrow.Arrow(2013, 5, 5, 2, 30, 00, 1),
                arrow.Arrow(2013, 5, 5, 2, 30, 59, 999999),
            ),
        ]

        assert result == expected


class TestArrowInterval:
    def test_incorrect_input(self):
        with pytest.raises(ValueError):
            list(
                arrow.Arrow.interval(
                    "month", datetime(2013, 1, 2), datetime(2013, 4, 15), 0
                )
            )

    def test_correct(self):
        result = list(
            arrow.Arrow.interval(
                "hour", datetime(2013, 5, 5, 12, 30), datetime(2013, 5, 5, 17, 15), 2
            )
        )

        assert result == [
            (
                arrow.Arrow(2013, 5, 5, 12),
                arrow.Arrow(2013, 5, 5, 13, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 14),
                arrow.Arrow(2013, 5, 5, 15, 59, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 16),
                arrow.Arrow(2013, 5, 5, 17, 59, 59, 999999),
            ),
        ]

    def test_bounds_param_is_passed(self):
        result = list(
            arrow.Arrow.interval(
                "hour",
                datetime(2013, 5, 5, 12, 30),
                datetime(2013, 5, 5, 17, 15),
                2,
                bounds="[]",
            )
        )

        assert result == [
            (arrow.Arrow(2013, 5, 5, 12), arrow.Arrow(2013, 5, 5, 14)),
            (arrow.Arrow(2013, 5, 5, 14), arrow.Arrow(2013, 5, 5, 16)),
            (arrow.Arrow(2013, 5, 5, 16), arrow.Arrow(2013, 5, 5, 18)),
        ]

    def test_exact(self):
        result = list(
            arrow.Arrow.interval(
                "hour",
                datetime(2013, 5, 5, 12, 30),
                datetime(2013, 5, 5, 17, 15),
                4,
                exact=True,
            )
        )

        expected = [
            (
                arrow.Arrow(2013, 5, 5, 12, 30),
                arrow.Arrow(2013, 5, 5, 16, 29, 59, 999999),
            ),
            (
                arrow.Arrow(2013, 5, 5, 16, 30),
                arrow.Arrow(2013, 5, 5, 17, 14, 59, 999999),
            ),
        ]

        assert result == expected


@pytest.mark.usefixtures("time_2013_02_15")
class TestArrowSpan:
    def test_span_attribute(self):
        with pytest.raises(ValueError):
            self.arrow.span("span")

    def test_span_year(self):
        floor, ceil = self.arrow.span("year")

        assert floor == datetime(2013, 1, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 12, 31, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_quarter(self):
        floor, ceil = self.arrow.span("quarter")

        assert floor == datetime(2013, 1, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 3, 31, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_quarter_count(self):
        floor, ceil = self.arrow.span("quarter", 2)

        assert floor == datetime(2013, 1, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 6, 30, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_year_count(self):
        floor, ceil = self.arrow.span("year", 2)

        assert floor == datetime(2013, 1, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2014, 12, 31, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_month(self):
        floor, ceil = self.arrow.span("month")

        assert floor == datetime(2013, 2, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 28, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_week(self):
        """
        >>> self.arrow.format("YYYY-MM-DD") == "2013-02-15"
        >>> self.arrow.isoweekday() == 5  # a Friday
        """
        # span week from Monday to Sunday
        floor, ceil = self.arrow.span("week")

        assert floor == datetime(2013, 2, 11, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 17, 23, 59, 59, 999999, tzinfo=tz.tzutc())
        # span week from Tuesday to Monday
        floor, ceil = self.arrow.span("week", week_start=2)

        assert floor == datetime(2013, 2, 12, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 18, 23, 59, 59, 999999, tzinfo=tz.tzutc())
        # span week from Saturday to Friday
        floor, ceil = self.arrow.span("week", week_start=6)

        assert floor == datetime(2013, 2, 9, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 23, 59, 59, 999999, tzinfo=tz.tzutc())
        # span week from Sunday to Saturday
        floor, ceil = self.arrow.span("week", week_start=7)

        assert floor == datetime(2013, 2, 10, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 16, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_day(self):
        floor, ceil = self.arrow.span("day")

        assert floor == datetime(2013, 2, 15, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 23, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_hour(self):
        floor, ceil = self.arrow.span("hour")

        assert floor == datetime(2013, 2, 15, 3, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_span_minute(self):
        floor, ceil = self.arrow.span("minute")

        assert floor == datetime(2013, 2, 15, 3, 41, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 41, 59, 999999, tzinfo=tz.tzutc())

    def test_span_second(self):
        floor, ceil = self.arrow.span("second")

        assert floor == datetime(2013, 2, 15, 3, 41, 22, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 41, 22, 999999, tzinfo=tz.tzutc())

    def test_span_microsecond(self):
        floor, ceil = self.arrow.span("microsecond")

        assert floor == datetime(2013, 2, 15, 3, 41, 22, 8923, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 41, 22, 8923, tzinfo=tz.tzutc())

    def test_floor(self):
        floor, ceil = self.arrow.span("month")

        assert floor == self.arrow.floor("month")
        assert ceil == self.arrow.ceil("month")

    def test_span_inclusive_inclusive(self):
        floor, ceil = self.arrow.span("hour", bounds="[]")

        assert floor == datetime(2013, 2, 15, 3, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 4, tzinfo=tz.tzutc())

    def test_span_exclusive_inclusive(self):
        floor, ceil = self.arrow.span("hour", bounds="(]")

        assert floor == datetime(2013, 2, 15, 3, 0, 0, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 4, tzinfo=tz.tzutc())

    def test_span_exclusive_exclusive(self):
        floor, ceil = self.arrow.span("hour", bounds="()")

        assert floor == datetime(2013, 2, 15, 3, 0, 0, 1, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 59, 59, 999999, tzinfo=tz.tzutc())

    def test_bounds_are_validated(self):
        with pytest.raises(ValueError):
            floor, ceil = self.arrow.span("hour", bounds="][")

    def test_exact(self):
        result_floor, result_ceil = self.arrow.span("hour", exact=True)

        expected_floor = datetime(2013, 2, 15, 3, 41, 22, 8923, tzinfo=tz.tzutc())
        expected_ceil = datetime(2013, 2, 15, 4, 41, 22, 8922, tzinfo=tz.tzutc())

        assert result_floor == expected_floor
        assert result_ceil == expected_ceil

    def test_exact_inclusive_inclusive(self):
        floor, ceil = self.arrow.span("minute", bounds="[]", exact=True)

        assert floor == datetime(2013, 2, 15, 3, 41, 22, 8923, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 42, 22, 8923, tzinfo=tz.tzutc())

    def test_exact_exclusive_inclusive(self):
        floor, ceil = self.arrow.span("day", bounds="(]", exact=True)

        assert floor == datetime(2013, 2, 15, 3, 41, 22, 8924, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 16, 3, 41, 22, 8923, tzinfo=tz.tzutc())

    def test_exact_exclusive_exclusive(self):
        floor, ceil = self.arrow.span("second", bounds="()", exact=True)

        assert floor == datetime(2013, 2, 15, 3, 41, 22, 8924, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 2, 15, 3, 41, 23, 8922, tzinfo=tz.tzutc())

    def test_all_parameters_specified(self):
        floor, ceil = self.arrow.span("week", bounds="()", exact=True, count=2)

        assert floor == datetime(2013, 2, 15, 3, 41, 22, 8924, tzinfo=tz.tzutc())
        assert ceil == datetime(2013, 3, 1, 3, 41, 22, 8922, tzinfo=tz.tzutc())


@pytest.mark.usefixtures("time_2013_01_01")
class TestArrowHumanize:
    def test_granularity(self):
        assert self.now.humanize(granularity="second") == "just now"

        later1 = self.now.shift(seconds=1)
        assert self.now.humanize(later1, granularity="second") == "just now"
        assert later1.humanize(self.now, granularity="second") == "just now"
        assert self.now.humanize(later1, granularity="minute") == "0 minutes ago"
        assert later1.humanize(self.now, granularity="minute") == "in 0 minutes"

        later100 = self.now.shift(seconds=100)
        assert self.now.humanize(later100, granularity="second") == "100 seconds ago"
        assert later100.humanize(self.now, granularity="second") == "in 100 seconds"
        assert self.now.humanize(later100, granularity="minute") == "a minute ago"
        assert later100.humanize(self.now, granularity="minute") == "in a minute"
        assert self.now.humanize(later100, granularity="hour") == "0 hours ago"
        assert later100.humanize(self.now, granularity="hour") == "in 0 hours"

        later4000 = self.now.shift(seconds=4000)
        assert self.now.humanize(later4000, granularity="minute") == "66 minutes ago"
        assert later4000.humanize(self.now, granularity="minute") == "in 66 minutes"
        assert self.now.humanize(later4000, granularity="hour") == "an hour ago"
        assert later4000.humanize(self.now, granularity="hour") == "in an hour"
        assert self.now.humanize(later4000, granularity="day") == "0 days ago"
        assert later4000.humanize(self.now, granularity="day") == "in 0 days"

        later105 = self.now.shift(seconds=10**5)
        assert self.now.humanize(later105, granularity="hour") == "27 hours ago"
        assert later105.humanize(self.now, granularity="hour") == "in 27 hours"
        assert self.now.humanize(later105, granularity="day") == "a day ago"
        assert later105.humanize(self.now, granularity="day") == "in a day"
        assert self.now.humanize(later105, granularity="week") == "0 weeks ago"
        assert later105.humanize(self.now, granularity="week") == "in 0 weeks"
        assert self.now.humanize(later105, granularity="month") == "0 months ago"
        assert later105.humanize(self.now, granularity="month") == "in 0 months"
        assert self.now.humanize(later105, granularity=["month"]) == "0 months ago"
        assert later105.humanize(self.now, granularity=["month"]) == "in 0 months"

        later106 = self.now.shift(seconds=3 * 10**6)
        assert self.now.humanize(later106, granularity="day") == "34 days ago"
        assert later106.humanize(self.now, granularity="day") == "in 34 days"
        assert self.now.humanize(later106, granularity="week") == "4 weeks ago"
        assert later106.humanize(self.now, granularity="week") == "in 4 weeks"
        assert self.now.humanize(later106, granularity="month") == "a month ago"
        assert later106.humanize(self.now, granularity="month") == "in a month"
        assert self.now.humanize(later106, granularity="year") == "0 years ago"
        assert later106.humanize(self.now, granularity="year") == "in 0 years"

        later506 = self.now.shift(seconds=50 * 10**6)
        assert self.now.humanize(later506, granularity="week") == "82 weeks ago"
        assert later506.humanize(self.now, granularity="week") == "in 82 weeks"
        assert self.now.humanize(later506, granularity="month") == "18 months ago"
        assert later506.humanize(self.now, granularity="month") == "in 18 months"
        assert self.now.humanize(later506, granularity="quarter") == "6 quarters ago"
        assert later506.humanize(self.now, granularity="quarter") == "in 6 quarters"
        assert self.now.humanize(later506, granularity="year") == "a year ago"
        assert later506.humanize(self.now, granularity="year") == "in a year"

        assert self.now.humanize(later1, granularity="quarter") == "0 quarters ago"
        assert later1.humanize(self.now, granularity="quarter") == "in 0 quarters"
        later107 = self.now.shift(seconds=10**7)
        assert self.now.humanize(later107, granularity="quarter") == "a quarter ago"
        assert later107.humanize(self.now, granularity="quarter") == "in a quarter"
        later207 = self.now.shift(seconds=2 * 10**7)
        assert self.now.humanize(later207, granularity="quarter") == "2 quarters ago"
        assert later207.humanize(self.now, granularity="quarter") == "in 2 quarters"
        later307 = self.now.shift(seconds=3 * 10**7)
        assert self.now.humanize(later307, granularity="quarter") == "3 quarters ago"
        assert later307.humanize(self.now, granularity="quarter") == "in 3 quarters"
        later377 = self.now.shift(seconds=3.7 * 10**7)
        assert self.now.humanize(later377, granularity="quarter") == "4 quarters ago"
        assert later377.humanize(self.now, granularity="quarter") == "in 4 quarters"
        later407 = self.now.shift(seconds=4 * 10**7)
        assert self.now.humanize(later407, granularity="quarter") == "5 quarters ago"
        assert later407.humanize(self.now, granularity="quarter") == "in 5 quarters"

        later108 = self.now.shift(seconds=10**8)
        assert self.now.humanize(later108, granularity="year") == "3 years ago"
        assert later108.humanize(self.now, granularity="year") == "in 3 years"

        later108onlydistance = self.now.shift(seconds=10**8)
        assert (
            self.now.humanize(
                later108onlydistance, only_distance=True, granularity="year"
            )
            == "3 years"
        )
        assert (
            later108onlydistance.humanize(
                self.now, only_distance=True, granularity="year"
            )
            == "3 years"
        )

        with pytest.raises(ValueError):
            self.now.humanize(later108, granularity="years")

    def test_multiple_granularity(self):
        assert self.now.humanize(granularity="second") == "just now"
        assert self.now.humanize(granularity=["second"]) == "just now"
        assert (
            self.now.humanize(granularity=["year", "month", "day", "hour", "second"])
            == "in 0 years 0 months 0 days 0 hours and 0 seconds"
        )

        later4000 = self.now.shift(seconds=4000)
        assert (
            later4000.humanize(self.now, granularity=["hour", "minute"])
            == "in an hour and 6 minutes"
        )
        assert (
            self.now.humanize(later4000, granularity=["hour", "minute"])
            == "an hour and 6 minutes ago"
        )
        assert (
            later4000.humanize(
                self.now, granularity=["hour", "minute"], only_distance=True
            )
            == "an hour and 6 minutes"
        )
        assert (
            later4000.humanize(self.now, granularity=["day", "hour", "minute"])
            == "in 0 days an hour and 6 minutes"
        )
        assert (
            self.now.humanize(later4000, granularity=["day", "hour", "minute"])
            == "0 days an hour and 6 minutes ago"
        )

        later105 = self.now.shift(seconds=10**5)
        assert (
            self.now.humanize(later105, granularity=["hour", "day", "minute"])
            == "a day 3 hours and 46 minutes ago"
        )
        with pytest.raises(ValueError):
            self.now.humanize(later105, granularity=["error", "second"])

        later108onlydistance = self.now.shift(seconds=10**8)
        assert (
            self.now.humanize(
                later108onlydistance, only_distance=True, granularity=["year"]
            )
            == "3 years"
        )
        assert (
            self.now.humanize(
                later108onlydistance, only_distance=True, granularity=["month", "week"]
            )
            == "37 months and 4 weeks"
        )
        # this will change when leap years are implemented
        assert (
            self.now.humanize(
                later108onlydistance, only_distance=True, granularity=["year", "second"]
            )
            == "3 years and 5392000 seconds"
        )

        one_min_one_sec_ago = self.now.shift(minutes=-1, seconds=-1)
        assert (
            one_min_one_sec_ago.humanize(self.now, granularity=["minute", "second"])
            == "a minute and a second ago"
        )

        one_min_two_secs_ago = self.now.shift(minutes=-1, seconds=-2)
        assert (
            one_min_two_secs_ago.humanize(self.now, granularity=["minute", "second"])
            == "a minute and 2 seconds ago"
        )

    def test_seconds(self):
        later = self.now.shift(seconds=10)

        # regression test for issue #727
        assert self.now.humanize(later) == "10 seconds ago"
        assert later.humanize(self.now) == "in 10 seconds"

        assert self.now.humanize(later, only_distance=True) == "10 seconds"
        assert later.humanize(self.now, only_distance=True) == "10 seconds"

    def test_minute(self):
        later = self.now.shift(minutes=1)

        assert self.now.humanize(later) == "a minute ago"
        assert later.humanize(self.now) == "in a minute"

        assert self.now.humanize(later, only_distance=True) == "a minute"
        assert later.humanize(self.now, only_distance=True) == "a minute"

    def test_minutes(self):
        later = self.now.shift(minutes=2)

        assert self.now.humanize(later) == "2 minutes ago"
        assert later.humanize(self.now) == "in 2 minutes"

        assert self.now.humanize(later, only_distance=True) == "2 minutes"
        assert later.humanize(self.now, only_distance=True) == "2 minutes"

    def test_hour(self):
        later = self.now.shift(hours=1)

        assert self.now.humanize(later) == "an hour ago"
        assert later.humanize(self.now) == "in an hour"

        assert self.now.humanize(later, only_distance=True) == "an hour"
        assert later.humanize(self.now, only_distance=True) == "an hour"

    def test_hours(self):
        later = self.now.shift(hours=2)

        assert self.now.humanize(later) == "2 hours ago"
        assert later.humanize(self.now) == "in 2 hours"

        assert self.now.humanize(later, only_distance=True) == "2 hours"
        assert later.humanize(self.now, only_distance=True) == "2 hours"

    def test_day(self):
        later = self.now.shift(days=1)

        assert self.now.humanize(later) == "a day ago"
        assert later.humanize(self.now) == "in a day"

        # regression test for issue #697
        less_than_48_hours = self.now.shift(
            days=1, hours=23, seconds=59, microseconds=999999
        )
        assert self.now.humanize(less_than_48_hours) == "a day ago"
        assert less_than_48_hours.humanize(self.now) == "in a day"

        less_than_48_hours_date = less_than_48_hours._datetime.date()
        with pytest.raises(TypeError):
            # humanize other argument does not take raw datetime.date objects
            self.now.humanize(less_than_48_hours_date)

        assert self.now.humanize(later, only_distance=True) == "a day"
        assert later.humanize(self.now, only_distance=True) == "a day"

    def test_days(self):
        later = self.now.shift(days=2)

        assert self.now.humanize(later) == "2 days ago"
        assert later.humanize(self.now) == "in 2 days"

        assert self.now.humanize(later, only_distance=True) == "2 days"
        assert later.humanize(self.now, only_distance=True) == "2 days"

        # Regression tests for humanize bug referenced in issue 541
        later = self.now.shift(days=3)
        assert later.humanize(self.now) == "in 3 days"

        later = self.now.shift(days=3, seconds=1)
        assert later.humanize(self.now) == "in 3 days"

        later = self.now.shift(days=4)
        assert later.humanize(self.now) == "in 4 days"

    def test_week(self):
        later = self.now.shift(weeks=1)

        assert self.now.humanize(later) == "a week ago"
        assert later.humanize(self.now) == "in a week"

        assert self.now.humanize(later, only_distance=True) == "a week"
        assert later.humanize(self.now, only_distance=True) == "a week"

    def test_weeks(self):
        later = self.now.shift(weeks=2)

        assert self.now.humanize(later) == "2 weeks ago"
        assert later.humanize(self.now) == "in 2 weeks"

        assert self.now.humanize(later, only_distance=True) == "2 weeks"
        assert later.humanize(self.now, only_distance=True) == "2 weeks"

    @pytest.mark.xfail(reason="known issue with humanize month limits")
    def test_month(self):
        later = self.now.shift(months=1)

        # TODO this test now returns "4 weeks ago", we need to fix this to be correct on a per month basis
        assert self.now.humanize(later) == "a month ago"
        assert later.humanize(self.now) == "in a month"

        assert self.now.humanize(later, only_distance=True) == "a month"
        assert later.humanize(self.now, only_distance=True) == "a month"

    def test_month_plus_4_days(self):
        # TODO needed for coverage, remove when month limits are fixed
        later = self.now.shift(months=1, days=4)

        assert self.now.humanize(later) == "a month ago"
        assert later.humanize(self.now) == "in a month"

    @pytest.mark.xfail(reason="known issue with humanize month limits")
    def test_months(self):
        later = self.now.shift(months=2)
        earlier = self.now.shift(months=-2)

        assert earlier.humanize(self.now) == "2 months ago"
        assert later.humanize(self.now) == "in 2 months"

        assert self.now.humanize(later, only_distance=True) == "2 months"
        assert later.humanize(self.now, only_distance=True) == "2 months"

    def test_year(self):
        later = self.now.shift(years=1)

        assert self.now.humanize(later) == "a year ago"
        assert later.humanize(self.now) == "in a year"

        assert self.now.humanize(later, only_distance=True) == "a year"
        assert later.humanize(self.now, only_distance=True) == "a year"

    def test_years(self):
        later = self.now.shift(years=2)

        assert self.now.humanize(later) == "2 years ago"
        assert later.humanize(self.now) == "in 2 years"

        assert self.now.humanize(later, only_distance=True) == "2 years"
        assert later.humanize(self.now, only_distance=True) == "2 years"

        arw = arrow.Arrow(2014, 7, 2)

        result = arw.humanize(self.datetime)

        assert result == "in a year"

    def test_arrow(self):
        arw = arrow.Arrow.fromdatetime(self.datetime)

        result = arw.humanize(arrow.Arrow.fromdatetime(self.datetime))

        assert result == "just now"

    def test_datetime_tzinfo(self):
        arw = arrow.Arrow.fromdatetime(self.datetime)

        result = arw.humanize(self.datetime.replace(tzinfo=tz.tzutc()))

        assert result == "just now"

    def test_other(self):
        arw = arrow.Arrow.fromdatetime(self.datetime)

        with pytest.raises(TypeError):
            arw.humanize(object())

    def test_invalid_locale(self):
        arw = arrow.Arrow.fromdatetime(self.datetime)

        with pytest.raises(ValueError):
            arw.humanize(locale="klingon")

    def test_none(self):
        arw = arrow.Arrow.utcnow()

        result = arw.humanize()

        assert result == "just now"

        result = arw.humanize(None)

        assert result == "just now"

    def test_week_limit(self):
        # regression test for issue #848
        arw = arrow.Arrow.utcnow()

        later = arw.shift(weeks=+1)

        result = arw.humanize(later)

        assert result == "a week ago"

    def test_untranslated_granularity(self, mocker):
        arw = arrow.Arrow.utcnow()
        later = arw.shift(weeks=1)

        # simulate an untranslated timeframe key
        mocker.patch.dict("arrow.locales.EnglishLocale.timeframes")
        del arrow.locales.EnglishLocale.timeframes["week"]
        with pytest.raises(ValueError):
            arw.humanize(later, granularity="week")

    def test_empty_granularity_list(self):
        arw = arrow.Arrow(2013, 1, 1, 0, 0, 0)
        later = arw.shift(seconds=55000)

        with pytest.raises(ValueError):
            arw.humanize(later, granularity=[])

    # Bulgarian is an example of a language that overrides _format_timeframe
    # Applicable to all locales. Note: Contributors need to make sure
    # that if they override describe or describe_multi, that delta
    # is truncated on call

    def test_no_floats(self):
        arw = arrow.Arrow(2013, 1, 1, 0, 0, 0)
        later = arw.shift(seconds=55000)
        humanize_string = arw.humanize(later, locale="bg", granularity="minute")
        assert humanize_string == "916 минути назад"

    def test_no_floats_multi_gran(self):
        arw = arrow.Arrow(2013, 1, 1, 0, 0, 0)
        later = arw.shift(seconds=55000)
        humanize_string = arw.humanize(
            later, locale="bg", granularity=["second", "minute"]
        )
        assert humanize_string == "916 минути 40 няколко секунди назад"


@pytest.mark.usefixtures("time_2013_01_01")
class TestArrowHumanizeTestsWithLocale:
    def test_now(self):
        arw = arrow.Arrow(2013, 1, 1, 0, 0, 0)

        result = arw.humanize(self.datetime, locale="ru")

        assert result == "сейчас"

    def test_seconds(self):
        arw = arrow.Arrow(2013, 1, 1, 0, 0, 44)

        result = arw.humanize(self.datetime, locale="ru")
        assert result == "через 44 секунды"

    def test_years(self):
        arw = arrow.Arrow(2011, 7, 2)

        result = arw.humanize(self.datetime, locale="ru")

        assert result == "год назад"


# Fixtures for Dehumanize
@pytest.fixture(scope="class")
def locale_list_no_weeks() -> List[str]:
    tested_langs = [
        "en",
        "en-us",
        "en-gb",
        "en-au",
        "en-be",
        "en-jp",
        "en-za",
        "en-ca",
        "en-ph",
        "fr",
        "fr-fr",
        "fr-ca",
        "it",
        "it-it",
        "es",
        "es-es",
        "el",
        "el-gr",
        "ja",
        "ja-jp",
        "sv",
        "sv-se",
        "fi",
        "fi-fi",
        "zh",
        "zh-cn",
        "zh-tw",
        "zh-hk",
        "nl",
        "nl-nl",
        "be",
        "be-by",
        "pl",
        "pl-pl",
        "ru",
        "ru-ru",
        "af",
        "bg",
        "bg-bg",
        "ua",
        "uk",
        "uk-ua",
        "mk",
        "mk-mk",
        "de",
        "de-de",
        "de-ch",
        "de-at",
        "nb",
        "nb-no",
        "nn",
        "nn-no",
        "pt",
        "pt-pt",
        "pt_br",
        "tl",
        "tl-ph",
        "vi",
        "vi-vn",
        "tr",
        "tr-tr",
        "az",
        "az-az",
        "da",
        "da-dk",
        "ml",
        "hi",
        "cs",
        "cs-cz",
        "sk",
        "sk-sk",
        "fa",
        "fa-ir",
        "mr",
        "ca",
        "ca-es",
        "ca-ad",
        "ca-fr",
        "ca-it",
        "eo",
        "eo-xx",
        "bn",
        "bn-bd",
        "bn-in",
        "rm",
        "rm-ch",
        "ro",
        "ro-ro",
        "sl",
        "sl-si",
        "id",
        "id-id",
        "ne",
        "ne-np",
        "ee",
        "et",
        "sw",
        "sw-ke",
        "sw-tz",
        "la",
        "la-va",
        "lt",
        "lt-lt",
        "ms",
        "ms-my",
        "ms-bn",
        "or",
        "or-in",
        "se",
        "se-fi",
        "se-no",
        "se-se",
        "lb",
        "lb-lu",
        "zu",
        "zu-za",
        "sq",
        "sq-al",
        "ta",
        "ta-in",
        "ta-lk",
        "ur",
        "ur-pk",
        "ka",
        "ka-ge",
        "kk",
        "kk-kz",
        "hy",
        "hy-am",
        "uz",
        "uz-uz",
        # "lo",
        # "lo-la",
    ]

    return tested_langs


@pytest.fixture(scope="class")
def locale_list_with_weeks() -> List[str]:
    tested_langs = [
        "en",
        "en-us",
        "en-gb",
        "en-au",
        "en-be",
        "en-jp",
        "en-za",
        "en-ca",
        "en-ph",
        "fr",
        "fr-fr",
        "fr-ca",
        "it",
        "it-it",
        "es",
        "es-es",
        "ja",
        "ja-jp",
        "sv",
        "sv-se",
        "zh",
        "zh-cn",
        "zh-tw",
        "zh-hk",
        "nl",
        "nl-nl",
        "pl",
        "pl-pl",
        "ru",
        "ru-ru",
        "mk",
        "mk-mk",
        "de",
        "de-de",
        "de-ch",
        "de-at",
        "pt",
        "pt-pt",
        "pt-br",
        "cs",
        "cs-cz",
        "sk",
        "sk-sk",
        "tl",
        "tl-ph",
        "vi",
        "vi-vn",
        "sw",
        "sw-ke",
        "sw-tz",
        "la",
        "la-va",
        "lt",
        "lt-lt",
        "ms",
        "ms-my",
        "ms-bn",
        "lb",
        "lb-lu",
        "zu",
        "zu-za",
        "ta",
        "ta-in",
        "ta-lk",
        "kk",
        "kk-kz",
        "hy",
        "hy-am",
        "uz",
        "uz-uz",
    ]

    return tested_langs


@pytest.fixture(scope="class")
def slavic_locales() -> List[str]:
    tested_langs = [
        "be",
        "be-by",
        "pl",
        "pl-pl",
        "ru",
        "ru-ru",
        "bg",
        "bg-bg",
        "ua",
        "uk",
        "uk-ua",
        "mk",
        "mk-mk",
    ]

    return tested_langs


class TestArrowDehumanize:
    def test_now(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
            second_ago = arw.shift(seconds=-1)
            second_future = arw.shift(seconds=1)

            second_ago_string = second_ago.humanize(
                arw, locale=lang, granularity=["second"]
            )
            second_future_string = second_future.humanize(
                arw, locale=lang, granularity=["second"]
            )

            assert arw.dehumanize(second_ago_string, locale=lang) == arw
            assert arw.dehumanize(second_future_string, locale=lang) == arw

    def test_seconds(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
            second_ago = arw.shift(seconds=-5)
            second_future = arw.shift(seconds=5)

            second_ago_string = second_ago.humanize(
                arw, locale=lang, granularity=["second"]
            )
            second_future_string = second_future.humanize(
                arw, locale=lang, granularity=["second"]
            )

            assert arw.dehumanize(second_ago_string, locale=lang) == second_ago
            assert arw.dehumanize(second_future_string, locale=lang) == second_future

    def test_minute(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2001, 6, 18, 5, 55, 0)
            minute_ago = arw.shift(minutes=-1)
            minute_future = arw.shift(minutes=1)

            minute_ago_string = minute_ago.humanize(
                arw, locale=lang, granularity=["minute"]
            )
            minute_future_string = minute_future.humanize(
                arw, locale=lang, granularity=["minute"]
            )

            assert arw.dehumanize(minute_ago_string, locale=lang) == minute_ago
            assert arw.dehumanize(minute_future_string, locale=lang) == minute_future

    def test_minutes(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2007, 1, 10, 5, 55, 0)
            minute_ago = arw.shift(minutes=-5)
            minute_future = arw.shift(minutes=5)

            minute_ago_string = minute_ago.humanize(
                arw, locale=lang, granularity=["minute"]
            )
            minute_future_string = minute_future.humanize(
                arw, locale=lang, granularity=["minute"]
            )

            assert arw.dehumanize(minute_ago_string, locale=lang) == minute_ago
            assert arw.dehumanize(minute_future_string, locale=lang) == minute_future

    def test_hour(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2009, 4, 20, 5, 55, 0)
            hour_ago = arw.shift(hours=-1)
            hour_future = arw.shift(hours=1)

            hour_ago_string = hour_ago.humanize(arw, locale=lang, granularity=["hour"])
            hour_future_string = hour_future.humanize(
                arw, locale=lang, granularity=["hour"]
            )

            assert arw.dehumanize(hour_ago_string, locale=lang) == hour_ago
            assert arw.dehumanize(hour_future_string, locale=lang) == hour_future

    def test_hours(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2010, 2, 16, 7, 55, 0)
            hour_ago = arw.shift(hours=-3)
            hour_future = arw.shift(hours=3)

            hour_ago_string = hour_ago.humanize(arw, locale=lang, granularity=["hour"])
            hour_future_string = hour_future.humanize(
                arw, locale=lang, granularity=["hour"]
            )

            assert arw.dehumanize(hour_ago_string, locale=lang) == hour_ago
            assert arw.dehumanize(hour_future_string, locale=lang) == hour_future

    def test_week(self, locale_list_with_weeks: List[str]):
        for lang in locale_list_with_weeks:
            arw = arrow.Arrow(2012, 2, 18, 1, 52, 0)
            week_ago = arw.shift(weeks=-1)
            week_future = arw.shift(weeks=1)

            week_ago_string = week_ago.humanize(arw, locale=lang, granularity=["week"])
            week_future_string = week_future.humanize(
                arw, locale=lang, granularity=["week"]
            )

            assert arw.dehumanize(week_ago_string, locale=lang) == week_ago
            assert arw.dehumanize(week_future_string, locale=lang) == week_future

    def test_weeks(self, locale_list_with_weeks: List[str]):
        for lang in locale_list_with_weeks:
            arw = arrow.Arrow(2020, 3, 18, 5, 3, 0)
            week_ago = arw.shift(weeks=-7)
            week_future = arw.shift(weeks=7)

            week_ago_string = week_ago.humanize(arw, locale=lang, granularity=["week"])
            week_future_string = week_future.humanize(
                arw, locale=lang, granularity=["week"]
            )

            assert arw.dehumanize(week_ago_string, locale=lang) == week_ago
            assert arw.dehumanize(week_future_string, locale=lang) == week_future

    def test_year(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            year_ago = arw.shift(years=-1)
            year_future = arw.shift(years=1)

            year_ago_string = year_ago.humanize(arw, locale=lang, granularity=["year"])
            year_future_string = year_future.humanize(
                arw, locale=lang, granularity=["year"]
            )

            assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
            assert arw.dehumanize(year_future_string, locale=lang) == year_future

    def test_years(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            year_ago = arw.shift(years=-10)
            year_future = arw.shift(years=10)

            year_ago_string = year_ago.humanize(arw, locale=lang, granularity=["year"])
            year_future_string = year_future.humanize(
                arw, locale=lang, granularity=["year"]
            )

            assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
            assert arw.dehumanize(year_future_string, locale=lang) == year_future

    def test_gt_than_10_years(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            year_ago = arw.shift(years=-25)
            year_future = arw.shift(years=25)

            year_ago_string = year_ago.humanize(arw, locale=lang, granularity=["year"])
            year_future_string = year_future.humanize(
                arw, locale=lang, granularity=["year"]
            )

            assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
            assert arw.dehumanize(year_future_string, locale=lang) == year_future

    def test_mixed_granularity(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            past = arw.shift(hours=-1, minutes=-1, seconds=-1)
            future = arw.shift(hours=1, minutes=1, seconds=1)

            past_string = past.humanize(
                arw, locale=lang, granularity=["hour", "minute", "second"]
            )
            future_string = future.humanize(
                arw, locale=lang, granularity=["hour", "minute", "second"]
            )

            assert arw.dehumanize(past_string, locale=lang) == past
            assert arw.dehumanize(future_string, locale=lang) == future

    def test_mixed_granularity_hours(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            past = arw.shift(hours=-3, minutes=-1, seconds=-15)
            future = arw.shift(hours=3, minutes=1, seconds=15)

            past_string = past.humanize(
                arw, locale=lang, granularity=["hour", "minute", "second"]
            )
            future_string = future.humanize(
                arw, locale=lang, granularity=["hour", "minute", "second"]
            )

            assert arw.dehumanize(past_string, locale=lang) == past
            assert arw.dehumanize(future_string, locale=lang) == future

    def test_mixed_granularity_day(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            past = arw.shift(days=-3, minutes=-1, seconds=-15)
            future = arw.shift(days=3, minutes=1, seconds=15)

            past_string = past.humanize(
                arw, locale=lang, granularity=["day", "minute", "second"]
            )
            future_string = future.humanize(
                arw, locale=lang, granularity=["day", "minute", "second"]
            )

            assert arw.dehumanize(past_string, locale=lang) == past
            assert arw.dehumanize(future_string, locale=lang) == future

    def test_mixed_granularity_day_hour(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 1, 10, 5, 55, 0)
            past = arw.shift(days=-3, hours=-23, seconds=-15)
            future = arw.shift(days=3, hours=23, seconds=15)

            past_string = past.humanize(
                arw, locale=lang, granularity=["day", "hour", "second"]
            )
            future_string = future.humanize(
                arw, locale=lang, granularity=["day", "hour", "second"]
            )

            assert arw.dehumanize(past_string, locale=lang) == past
            assert arw.dehumanize(future_string, locale=lang) == future

    # Test to make sure unsupported locales error out
    def test_unsupported_locale(self):
        arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
        second_ago = arw.shift(seconds=-5)
        second_future = arw.shift(seconds=5)

        second_ago_string = second_ago.humanize(
            arw, locale="ko", granularity=["second"]
        )
        second_future_string = second_future.humanize(
            arw, locale="ko", granularity=["second"]
        )

        # ko is an example of many unsupported locales currently
        with pytest.raises(ValueError):
            arw.dehumanize(second_ago_string, locale="ko")

        with pytest.raises(ValueError):
            arw.dehumanize(second_future_string, locale="ko")

    # Test to ensure old style locale strings are supported
    def test_normalized_locale(self):
        arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
        second_ago = arw.shift(seconds=-5)
        second_future = arw.shift(seconds=5)

        second_ago_string = second_ago.humanize(
            arw, locale="zh_hk", granularity=["second"]
        )
        second_future_string = second_future.humanize(
            arw, locale="zh_hk", granularity=["second"]
        )

        assert arw.dehumanize(second_ago_string, locale="zh_hk") == second_ago
        assert arw.dehumanize(second_future_string, locale="zh_hk") == second_future

    # Ensures relative units are required in string
    def test_require_relative_unit(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
            second_ago = arw.shift(seconds=-5)
            second_future = arw.shift(seconds=5)

            second_ago_string = second_ago.humanize(
                arw, locale=lang, granularity=["second"], only_distance=True
            )
            second_future_string = second_future.humanize(
                arw, locale=lang, granularity=["second"], only_distance=True
            )

            with pytest.raises(ValueError):
                arw.dehumanize(second_ago_string, locale=lang)

            with pytest.raises(ValueError):
                arw.dehumanize(second_future_string, locale=lang)

    # Test for scrambled input
    def test_scrambled_input(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)
            second_ago = arw.shift(seconds=-5)
            second_future = arw.shift(seconds=5)

            second_ago_string = second_ago.humanize(
                arw, locale=lang, granularity=["second"], only_distance=True
            )
            second_future_string = second_future.humanize(
                arw, locale=lang, granularity=["second"], only_distance=True
            )

            # Scrambles input by sorting strings
            second_ago_presort = sorted(second_ago_string)
            second_ago_string = "".join(second_ago_presort)

            second_future_presort = sorted(second_future_string)
            second_future_string = "".join(second_future_presort)

            with pytest.raises(ValueError):
                arw.dehumanize(second_ago_string, locale=lang)

            with pytest.raises(ValueError):
                arw.dehumanize(second_future_string, locale=lang)

    def test_no_units_modified(self, locale_list_no_weeks: List[str]):
        for lang in locale_list_no_weeks:
            arw = arrow.Arrow(2000, 6, 18, 5, 55, 0)

            # Ensures we pass the first stage of checking whether relative units exist
            locale_obj = locales.get_locale(lang)
            empty_past_string = locale_obj.past
            empty_future_string = locale_obj.future

            with pytest.raises(ValueError):
                arw.dehumanize(empty_past_string, locale=lang)

            with pytest.raises(ValueError):
                arw.dehumanize(empty_future_string, locale=lang)

    def test_slavic_locales(self, slavic_locales: List[str]):
        # Relevant units for Slavic locale plural logic
        units = [
            0,
            1,
            2,
            5,
            21,
            22,
            25,
        ]

        # Only need to test on seconds as logic holds for all slavic plural units
        for lang in slavic_locales:
            for unit in units:
                arw = arrow.Arrow(2000, 2, 18, 1, 50, 30)

                past = arw.shift(minutes=-1 * unit, days=-1)
                future = arw.shift(minutes=unit, days=1)

                past_string = past.humanize(
                    arw, locale=lang, granularity=["minute", "day"]
                )
                future_string = future.humanize(
                    arw, locale=lang, granularity=["minute", "day"]
                )

                assert arw.dehumanize(past_string, locale=lang) == past
                assert arw.dehumanize(future_string, locale=lang) == future

    def test_czech_slovak(self):
        # Relevant units for Slavic locale plural logic
        units = [
            0,
            1,
            2,
            5,
        ]

        # Only need to test on seconds as logic holds for all slavic plural units
        for lang in ["cs"]:
            for unit in units:
                arw = arrow.Arrow(2000, 2, 18, 1, 50, 30)

                past = arw.shift(minutes=-1 * unit, days=-1)
                future = arw.shift(minutes=unit, days=1)

                past_string = past.humanize(
                    arw, locale=lang, granularity=["minute", "day"]
                )
                future_string = future.humanize(
                    arw, locale=lang, granularity=["minute", "day"]
                )

                assert arw.dehumanize(past_string, locale=lang) == past
                assert arw.dehumanize(future_string, locale=lang) == future


class TestArrowIsBetween:
    def test_start_before_end(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 8))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
        assert not target.is_between(start, end)

    def test_exclusive_exclusive_bounds(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 5, 12, 30, 27))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5, 12, 30, 10))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 5, 12, 30, 36))
        assert target.is_between(start, end, "()")

    def test_exclusive_exclusive_bounds_same_date(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        assert not target.is_between(start, end, "()")

    def test_inclusive_exclusive_bounds(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 6))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 4))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 6))
        assert not target.is_between(start, end, "[)")

    def test_exclusive_inclusive_bounds(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        assert target.is_between(start, end, "(]")

    def test_inclusive_inclusive_bounds_same_date(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        assert target.is_between(start, end, "[]")

    def test_inclusive_inclusive_bounds_target_before_start(self):
        target = arrow.Arrow.fromdatetime(datetime(2020, 12, 24))
        start = arrow.Arrow.fromdatetime(datetime(2020, 12, 25))
        end = arrow.Arrow.fromdatetime(datetime(2020, 12, 26))
        assert not target.is_between(start, end, "[]")

    def test_type_error_exception(self):
        with pytest.raises(TypeError):
            target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
            start = datetime(2013, 5, 5)
            end = arrow.Arrow.fromdatetime(datetime(2013, 5, 8))
            target.is_between(start, end)

        with pytest.raises(TypeError):
            target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
            start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
            end = datetime(2013, 5, 8)
            target.is_between(start, end)

        with pytest.raises(TypeError):
            target.is_between(None, None)

    def test_value_error_exception(self):
        target = arrow.Arrow.fromdatetime(datetime(2013, 5, 7))
        start = arrow.Arrow.fromdatetime(datetime(2013, 5, 5))
        end = arrow.Arrow.fromdatetime(datetime(2013, 5, 8))
        with pytest.raises(ValueError):
            target.is_between(start, end, "][")
        with pytest.raises(ValueError):
            target.is_between(start, end, "")
        with pytest.raises(ValueError):
            target.is_between(start, end, "]")
        with pytest.raises(ValueError):
            target.is_between(start, end, "[")
        with pytest.raises(ValueError):
            target.is_between(start, end, "hello")
        with pytest.raises(ValueError):
            target.span("week", week_start=55)


class TestArrowUtil:
    def test_get_datetime(self):
        get_datetime = arrow.Arrow._get_datetime

        arw = arrow.Arrow.utcnow()
        dt = datetime.utcnow()
        timestamp = time.time()

        assert get_datetime(arw) == arw.datetime
        assert get_datetime(dt) == dt
        assert (
            get_datetime(timestamp) == arrow.Arrow.utcfromtimestamp(timestamp).datetime
        )

        with pytest.raises(ValueError) as raise_ctx:
            get_datetime("abc")
        assert "not recognized as a datetime or timestamp" in str(raise_ctx.value)

    def test_get_tzinfo(self):
        get_tzinfo = arrow.Arrow._get_tzinfo

        with pytest.raises(ValueError) as raise_ctx:
            get_tzinfo("abc")
        assert "not recognized as a timezone" in str(raise_ctx.value)

    def test_get_iteration_params(self):
        assert arrow.Arrow._get_iteration_params("end", None) == ("end", sys.maxsize)
        assert arrow.Arrow._get_iteration_params(None, 100) == (arrow.Arrow.max, 100)
        assert arrow.Arrow._get_iteration_params(100, 120) == (100, 120)

        with pytest.raises(ValueError):
            arrow.Arrow._get_iteration_params(None, None)