@@ -54,71 +54,71 @@ def test_period_deprecation(instant):
5454 """Throws a deprecation warning when called."""
5555
5656 with pytest .warns (DeprecationWarning ):
57- instant .period (DateUnit .DAY )
57+ instant .period (DateUnit .DAY . value )
5858
5959
6060def test_period_for_eternity (instant ):
6161 """Throws an AssertionError when called with the eternity unit."""
6262
6363 with pytest .raises (AssertionError , match = "eternity" ):
64- instant .period (DateUnit .ETERNITY )
64+ instant .period (DateUnit .ETERNITY . value )
6565
6666
6767def test_period_with_invalid_size (instant ):
6868 """Throws an AssertionError when called with an invalid size."""
6969
7070 with pytest .raises (AssertionError , match = "int >= 1" ):
71- instant .period (DateUnit .DAY , size = 0 )
71+ instant .period (DateUnit .DAY . value , size = 0 )
7272
7373
7474def test_offset_for_eternity (instant ):
7575 """Throws an AssertionError when called with the eternity unit."""
7676
7777 with pytest .raises (AssertionError , match = "eternity" ):
78- instant .offset ("first-of" , DateUnit .ETERNITY )
78+ instant .offset ("first-of" , DateUnit .ETERNITY . value )
7979
8080
8181def test_offset_with_invalid_offset (instant ):
8282 """Throws an AssertionError when called with an invalid offset."""
8383
8484 with pytest .raises (AssertionError , match = "any int" ):
85- instant .offset ("doomsday" , DateUnit .YEAR )
85+ instant .offset ("doomsday" , DateUnit .YEAR . value )
8686
8787
8888@pytest .mark .parametrize ("actual, offset, expected" , [
89- ((2020 , 1 , 1 ), (1 , DateUnit .DAY ), (2020 , 1 , 2 )),
90- ((2020 , 1 , 1 ), (1 , DateUnit .MONTH ), (2020 , 2 , 1 )),
91- ((2020 , 1 , 1 ), (1 , DateUnit .YEAR ), (2021 , 1 , 1 )),
92- ((2020 , 1 , 31 ), (1 , DateUnit .DAY ), (2020 , 2 , 1 )),
93- ((2020 , 1 , 31 ), (1 , DateUnit .MONTH ), (2020 , 2 , 29 )),
94- ((2020 , 1 , 31 ), (1 , DateUnit .YEAR ), (2021 , 1 , 31 )),
95- ((2020 , 2 , 28 ), (1 , DateUnit .DAY ), (2020 , 2 , 29 )),
96- ((2020 , 2 , 28 ), (1 , DateUnit .MONTH ), (2020 , 3 , 28 )),
97- ((2020 , 2 , 29 ), (1 , DateUnit .YEAR ), (2021 , 2 , 28 )),
98- ((2020 , 1 , 1 ), (- 1 , DateUnit .DAY ), (2019 , 12 , 31 )),
99- ((2020 , 1 , 1 ), (- 1 , DateUnit .MONTH ), (2019 , 12 , 1 )),
100- ((2020 , 1 , 1 ), (- 1 , DateUnit .YEAR ), (2019 , 1 , 1 )),
101- ((2020 , 3 , 1 ), (- 1 , DateUnit .DAY ), (2020 , 2 , 29 )),
102- ((2020 , 3 , 31 ), (- 1 , DateUnit .MONTH ), (2020 , 2 , 29 )),
103- ((2020 , 2 , 29 ), (- 1 , DateUnit .YEAR ), (2019 , 2 , 28 )),
104- ((2020 , 1 , 30 ), (3 , DateUnit .DAY ), (2020 , 2 , 2 )),
105- ((2020 , 10 , 2 ), (3 , DateUnit .MONTH ), (2021 , 1 , 2 )),
106- ((2020 , 1 , 1 ), (3 , DateUnit .YEAR ), (2023 , 1 , 1 )),
107- ((2020 , 1 , 1 ), (- 3 , DateUnit .DAY ), (2019 , 12 , 29 )),
108- ((2020 , 1 , 1 ), (- 3 , DateUnit .MONTH ), (2019 , 10 , 1 )),
109- ((2020 , 1 , 1 ), (- 3 , DateUnit .YEAR ), (2017 , 1 , 1 )),
110- ((2020 , 1 , 1 ), ("first-of" , DateUnit .MONTH ), (2020 , 1 , 1 )),
111- ((2020 , 2 , 1 ), ("first-of" , DateUnit .MONTH ), (2020 , 2 , 1 )),
112- ((2020 , 2 , 3 ), ("first-of" , DateUnit .MONTH ), (2020 , 2 , 1 )),
113- ((2020 , 1 , 1 ), ("first-of" , DateUnit .YEAR ), (2020 , 1 , 1 )),
114- ((2020 , 2 , 1 ), ("first-of" , DateUnit .YEAR ), (2020 , 1 , 1 )),
115- ((2020 , 2 , 3 ), ("first-of" , DateUnit .YEAR ), (2020 , 1 , 1 )),
116- ((2020 , 1 , 1 ), ("last-of" , DateUnit .MONTH ), (2020 , 1 , 31 )),
117- ((2020 , 2 , 1 ), ("last-of" , DateUnit .MONTH ), (2020 , 2 , 29 )),
118- ((2020 , 2 , 3 ), ("last-of" , DateUnit .MONTH ), (2020 , 2 , 29 )),
119- ((2020 , 1 , 1 ), ("last-of" , DateUnit .YEAR ), (2020 , 12 , 31 )),
120- ((2020 , 2 , 1 ), ("last-of" , DateUnit .YEAR ), (2020 , 12 , 31 )),
121- ((2020 , 2 , 3 ), ("last-of" , DateUnit .YEAR ), (2020 , 12 , 31 )),
89+ ((2020 , 1 , 1 ), (1 , DateUnit .DAY . value ), (2020 , 1 , 2 )),
90+ ((2020 , 1 , 1 ), (1 , DateUnit .MONTH . value ), (2020 , 2 , 1 )),
91+ ((2020 , 1 , 1 ), (1 , DateUnit .YEAR . value ), (2021 , 1 , 1 )),
92+ ((2020 , 1 , 31 ), (1 , DateUnit .DAY . value ), (2020 , 2 , 1 )),
93+ ((2020 , 1 , 31 ), (1 , DateUnit .MONTH . value ), (2020 , 2 , 29 )),
94+ ((2020 , 1 , 31 ), (1 , DateUnit .YEAR . value ), (2021 , 1 , 31 )),
95+ ((2020 , 2 , 28 ), (1 , DateUnit .DAY . value ), (2020 , 2 , 29 )),
96+ ((2020 , 2 , 28 ), (1 , DateUnit .MONTH . value ), (2020 , 3 , 28 )),
97+ ((2020 , 2 , 29 ), (1 , DateUnit .YEAR . value ), (2021 , 2 , 28 )),
98+ ((2020 , 1 , 1 ), (- 1 , DateUnit .DAY . value ), (2019 , 12 , 31 )),
99+ ((2020 , 1 , 1 ), (- 1 , DateUnit .MONTH . value ), (2019 , 12 , 1 )),
100+ ((2020 , 1 , 1 ), (- 1 , DateUnit .YEAR . value ), (2019 , 1 , 1 )),
101+ ((2020 , 3 , 1 ), (- 1 , DateUnit .DAY . value ), (2020 , 2 , 29 )),
102+ ((2020 , 3 , 31 ), (- 1 , DateUnit .MONTH . value ), (2020 , 2 , 29 )),
103+ ((2020 , 2 , 29 ), (- 1 , DateUnit .YEAR . value ), (2019 , 2 , 28 )),
104+ ((2020 , 1 , 30 ), (3 , DateUnit .DAY . value ), (2020 , 2 , 2 )),
105+ ((2020 , 10 , 2 ), (3 , DateUnit .MONTH . value ), (2021 , 1 , 2 )),
106+ ((2020 , 1 , 1 ), (3 , DateUnit .YEAR . value ), (2023 , 1 , 1 )),
107+ ((2020 , 1 , 1 ), (- 3 , DateUnit .DAY . value ), (2019 , 12 , 29 )),
108+ ((2020 , 1 , 1 ), (- 3 , DateUnit .MONTH . value ), (2019 , 10 , 1 )),
109+ ((2020 , 1 , 1 ), (- 3 , DateUnit .YEAR . value ), (2017 , 1 , 1 )),
110+ ((2020 , 1 , 1 ), ("first-of" , DateUnit .MONTH . value ), (2020 , 1 , 1 )),
111+ ((2020 , 2 , 1 ), ("first-of" , DateUnit .MONTH . value ), (2020 , 2 , 1 )),
112+ ((2020 , 2 , 3 ), ("first-of" , DateUnit .MONTH . value ), (2020 , 2 , 1 )),
113+ ((2020 , 1 , 1 ), ("first-of" , DateUnit .YEAR . value ), (2020 , 1 , 1 )),
114+ ((2020 , 2 , 1 ), ("first-of" , DateUnit .YEAR . value ), (2020 , 1 , 1 )),
115+ ((2020 , 2 , 3 ), ("first-of" , DateUnit .YEAR . value ), (2020 , 1 , 1 )),
116+ ((2020 , 1 , 1 ), ("last-of" , DateUnit .MONTH . value ), (2020 , 1 , 31 )),
117+ ((2020 , 2 , 1 ), ("last-of" , DateUnit .MONTH . value ), (2020 , 2 , 29 )),
118+ ((2020 , 2 , 3 ), ("last-of" , DateUnit .MONTH . value ), (2020 , 2 , 29 )),
119+ ((2020 , 1 , 1 ), ("last-of" , DateUnit .YEAR . value ), (2020 , 12 , 31 )),
120+ ((2020 , 2 , 1 ), ("last-of" , DateUnit .YEAR . value ), (2020 , 12 , 31 )),
121+ ((2020 , 2 , 3 ), ("last-of" , DateUnit .YEAR . value ), (2020 , 12 , 31 )),
122122 ])
123123def test_offset (actual , offset , expected ):
124124 """It works ;)."""
0 commit comments