File tree Expand file tree Collapse file tree 2 files changed +172
-0
lines changed Expand file tree Collapse file tree 2 files changed +172
-0
lines changed Original file line number Diff line number Diff line change 11import itertools
2+ import random
23
34import pytest
5+
46from commitizen .version_schemes import Pep440 , VersionProtocol
57
68simple_flow = [
140142]
141143
142144
145+ # test driven development
146+ sortability = [
147+ "0.10.0a0" ,
148+ "0.1.1" ,
149+ "0.1.2" ,
150+ "2.1.1" ,
151+ "3.0.0" ,
152+ "0.9.1a0" ,
153+ "1.0.0a1" ,
154+ "1.0.0b1" ,
155+ "1.0.0a1" ,
156+ "1.0.0a2.dev1" ,
157+ "1.0.0rc2" ,
158+ "1.0.0a3.dev0" ,
159+ "1.0.0a2.dev0" ,
160+ "1.0.0a3.dev1" ,
161+ "1.0.0a2.dev0" ,
162+ "1.0.0b0" ,
163+ "1.0.0rc0" ,
164+ "1.0.0rc1" ,
165+ ]
166+
167+
143168@pytest .mark .parametrize (
144169 "test_input,expected" ,
145170 itertools .chain (
@@ -198,3 +223,76 @@ def test_pep440_scheme_property():
198223
199224def test_pep440_implement_version_protocol ():
200225 assert isinstance (Pep440 ("0.0.1" ), VersionProtocol )
226+
227+
228+ def test_pep440_sortable ():
229+ test_input = [x [0 ][0 ] for x in simple_flow ]
230+ test_input .extend ([x [1 ] for x in simple_flow ])
231+ # randomize
232+ random_input = [Pep440 (x ) for x in random .sample (test_input , len (test_input ))]
233+ assert len (random_input ) == len (test_input )
234+ sorted_result = [str (x ) for x in sorted (random_input )]
235+ assert sorted_result == [
236+ "0.1.0" ,
237+ "0.1.0" ,
238+ "0.1.1.dev1" ,
239+ "0.1.1" ,
240+ "0.1.1" ,
241+ "0.2.0" ,
242+ "0.2.0" ,
243+ "0.2.0" ,
244+ "0.3.0.dev1" ,
245+ "0.3.0" ,
246+ "0.3.0" ,
247+ "0.3.0" ,
248+ "0.3.0" ,
249+ "0.3.1a0" ,
250+ "0.3.1a0" ,
251+ "0.3.1a0" ,
252+ "0.3.1a0" ,
253+ "0.3.1a1" ,
254+ "0.3.1a1" ,
255+ "0.3.1a1" ,
256+ "0.3.1" ,
257+ "0.3.1" ,
258+ "0.3.1" ,
259+ "0.3.2" ,
260+ "0.4.2" ,
261+ "1.0.0a0" ,
262+ "1.0.0a0" ,
263+ "1.0.0a1" ,
264+ "1.0.0a1" ,
265+ "1.0.0a1" ,
266+ "1.0.0a1" ,
267+ "1.0.0a2.dev0" ,
268+ "1.0.0a2.dev0" ,
269+ "1.0.0a2.dev1" ,
270+ "1.0.0a2" ,
271+ "1.0.0a3.dev0" ,
272+ "1.0.0a3.dev0" ,
273+ "1.0.0a3.dev1" ,
274+ "1.0.0b0" ,
275+ "1.0.0b0" ,
276+ "1.0.0b0" ,
277+ "1.0.0b1" ,
278+ "1.0.0b1" ,
279+ "1.0.0rc0" ,
280+ "1.0.0rc0" ,
281+ "1.0.0rc0" ,
282+ "1.0.0rc0" ,
283+ "1.0.0rc1.dev1" ,
284+ "1.0.0rc1" ,
285+ "1.0.0" ,
286+ "1.0.0" ,
287+ "1.0.1" ,
288+ "1.0.1" ,
289+ "1.0.2" ,
290+ "1.0.2" ,
291+ "1.1.0" ,
292+ "1.1.0" ,
293+ "1.2.0" ,
294+ "1.2.0" ,
295+ "1.2.1" ,
296+ "1.2.1" ,
297+ "2.0.0" ,
298+ ]
Original file line number Diff line number Diff line change 11import itertools
2+ import random
23
34import pytest
45
@@ -135,3 +136,76 @@ def test_semver_scheme_property():
135136
136137def test_semver_implement_version_protocol ():
137138 assert isinstance (SemVer ("0.0.1" ), VersionProtocol )
139+
140+
141+ def test_semver_sortable ():
142+ test_input = [x [0 ][0 ] for x in simple_flow ]
143+ test_input .extend ([x [1 ] for x in simple_flow ])
144+ # randomize
145+ random_input = [SemVer (x ) for x in random .sample (test_input , len (test_input ))]
146+ assert len (random_input ) == len (test_input )
147+ sorted_result = [str (x ) for x in sorted (random_input )]
148+ assert sorted_result == [
149+ "0.1.0" ,
150+ "0.1.0" ,
151+ "0.1.1-dev1" ,
152+ "0.1.1" ,
153+ "0.1.1" ,
154+ "0.2.0" ,
155+ "0.2.0" ,
156+ "0.2.0" ,
157+ "0.3.0-dev1" ,
158+ "0.3.0" ,
159+ "0.3.0" ,
160+ "0.3.0" ,
161+ "0.3.0" ,
162+ "0.3.1-a0" ,
163+ "0.3.1-a0" ,
164+ "0.3.1-a0" ,
165+ "0.3.1-a0" ,
166+ "0.3.1-a1" ,
167+ "0.3.1-a1" ,
168+ "0.3.1-a1" ,
169+ "0.3.1" ,
170+ "0.3.1" ,
171+ "0.3.1" ,
172+ "0.3.2" ,
173+ "0.4.2" ,
174+ "1.0.0-a0" ,
175+ "1.0.0-a0" ,
176+ "1.0.0-a1" ,
177+ "1.0.0-a1" ,
178+ "1.0.0-a1" ,
179+ "1.0.0-a1" ,
180+ "1.0.0-a2-dev0" ,
181+ "1.0.0-a2-dev0" ,
182+ "1.0.0-a2-dev1" ,
183+ "1.0.0-a2" ,
184+ "1.0.0-a3-dev0" ,
185+ "1.0.0-a3-dev0" ,
186+ "1.0.0-a3-dev1" ,
187+ "1.0.0-b0" ,
188+ "1.0.0-b0" ,
189+ "1.0.0-b0" ,
190+ "1.0.0-b1" ,
191+ "1.0.0-b1" ,
192+ "1.0.0-rc0" ,
193+ "1.0.0-rc0" ,
194+ "1.0.0-rc0" ,
195+ "1.0.0-rc0" ,
196+ "1.0.0-rc1-dev1" ,
197+ "1.0.0-rc1" ,
198+ "1.0.0" ,
199+ "1.0.0" ,
200+ "1.0.1" ,
201+ "1.0.1" ,
202+ "1.0.2" ,
203+ "1.0.2" ,
204+ "1.1.0" ,
205+ "1.1.0" ,
206+ "1.2.0" ,
207+ "1.2.0" ,
208+ "1.2.1" ,
209+ "1.2.1" ,
210+ "2.0.0" ,
211+ ]
You can’t perform that action at this time.
0 commit comments