Skip to content

Commit aa3bf05

Browse files
committed
Split tests
1 parent c9662f0 commit aa3bf05

3 files changed

Lines changed: 136 additions & 132 deletions

File tree

tests/test_blurb.py

Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -93,138 +93,6 @@ def test_sortable_datetime():
9393
assert blurb.sortable_datetime() == "2025-01-07-16-28-41"
9494

9595

96-
@pytest.mark.parametrize(
97-
"version1, version2",
98-
(
99-
("2", "3"),
100-
("3.5.0a1", "3.5.0b1"),
101-
("3.5.0a1", "3.5.0rc1"),
102-
("3.5.0a1", "3.5.0"),
103-
("3.6.0b1", "3.6.0b2"),
104-
("3.6.0b1", "3.6.0rc1"),
105-
("3.6.0b1", "3.6.0"),
106-
("3.7.0rc1", "3.7.0rc2"),
107-
("3.7.0rc1", "3.7.0"),
108-
("3.8", "3.8.1"),
109-
),
110-
)
111-
def test_version_key(version1, version2):
112-
# Act
113-
key1 = blurb.version_key(version1)
114-
key2 = blurb.version_key(version2)
115-
116-
# Assert
117-
assert key1 < key2
118-
119-
120-
def test_glob_versions(fs):
121-
# Arrange
122-
fake_version_blurbs = (
123-
"Misc/NEWS.d/3.7.0.rst",
124-
"Misc/NEWS.d/3.7.0a1.rst",
125-
"Misc/NEWS.d/3.7.0a2.rst",
126-
"Misc/NEWS.d/3.7.0b1.rst",
127-
"Misc/NEWS.d/3.7.0b2.rst",
128-
"Misc/NEWS.d/3.7.0rc1.rst",
129-
"Misc/NEWS.d/3.7.0rc2.rst",
130-
"Misc/NEWS.d/3.9.0b1.rst",
131-
"Misc/NEWS.d/3.12.0a1.rst",
132-
)
133-
for fn in fake_version_blurbs:
134-
fs.create_file(fn)
135-
136-
# Act
137-
versions = blurb.glob_versions()
138-
139-
# Assert
140-
assert versions == [
141-
"3.12.0a1",
142-
"3.9.0b1",
143-
"3.7.0",
144-
"3.7.0rc2",
145-
"3.7.0rc1",
146-
"3.7.0b2",
147-
"3.7.0b1",
148-
"3.7.0a2",
149-
"3.7.0a1",
150-
]
151-
152-
153-
def test_glob_blurbs_next(fs):
154-
# Arrange
155-
fake_news_entries = (
156-
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-11111.pC7gnM.rst",
157-
"Misc/NEWS.d/next/Core and Builtins/2023-03-17-12-09-45.gh-issue-33333.Pf_BI7.rst",
158-
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-44444.2F1Byz.rst",
159-
"Misc/NEWS.d/next/C API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
160-
)
161-
fake_readmes = (
162-
"Misc/NEWS.d/next/Library/README.rst",
163-
"Misc/NEWS.d/next/Core and Builtins/README.rst",
164-
"Misc/NEWS.d/next/Tools-Demos/README.rst",
165-
"Misc/NEWS.d/next/C API/README.rst",
166-
)
167-
for fn in fake_news_entries + fake_readmes:
168-
fs.create_file(fn)
169-
170-
# Act
171-
filenames = blurb.glob_blurbs("next")
172-
173-
# Assert
174-
assert set(filenames) == set(fake_news_entries)
175-
176-
177-
def test_glob_blurbs_sort_order(fs):
178-
"""
179-
It shouldn't make a difference to sorting whether
180-
section names have spaces or underscores.
181-
"""
182-
# Arrange
183-
fake_news_entries = (
184-
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-01-00.gh-issue-33331.Pf_BI1.rst",
185-
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-02-00.gh-issue-33332.Pf_BI2.rst",
186-
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-03-00.gh-issue-33333.Pf_BI3.rst",
187-
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-04-00.gh-issue-33334.Pf_BI4.rst",
188-
)
189-
# As fake_news_entries, but reverse sorted by *filename* only
190-
expected = [
191-
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-04-00.gh-issue-33334.Pf_BI4.rst",
192-
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-03-00.gh-issue-33333.Pf_BI3.rst",
193-
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-02-00.gh-issue-33332.Pf_BI2.rst",
194-
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-01-00.gh-issue-33331.Pf_BI1.rst",
195-
]
196-
fake_readmes = (
197-
"Misc/NEWS.d/next/Library/README.rst",
198-
"Misc/NEWS.d/next/Core and Builtins/README.rst",
199-
"Misc/NEWS.d/next/Tools-Demos/README.rst",
200-
"Misc/NEWS.d/next/C API/README.rst",
201-
)
202-
for fn in fake_news_entries + fake_readmes:
203-
fs.create_file(fn)
204-
205-
# Act
206-
filenames = blurb.glob_blurbs("next")
207-
208-
# Assert
209-
assert filenames == expected
210-
211-
212-
@pytest.mark.parametrize(
213-
"version, expected",
214-
(
215-
("next", "next"),
216-
("3.12.0a1", "3.12.0 alpha 1"),
217-
("3.12.0b2", "3.12.0 beta 2"),
218-
("3.12.0rc2", "3.12.0 release candidate 2"),
219-
("3.12.0", "3.12.0 final"),
220-
("3.12.1", "3.12.1 final"),
221-
),
222-
)
223-
def test_printable_version(version, expected):
224-
# Act / Assert
225-
assert blurb.printable_version(version) == expected
226-
227-
22896
@pytest.mark.parametrize(
22997
"news_entry, expected_section",
23098
(

tests/test_merge.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from blurb._merge import glob_blurbs
2+
3+
4+
def test_glob_blurbs_next(fs):
5+
# Arrange
6+
fake_news_entries = (
7+
"Misc/NEWS.d/next/Library/2022-04-11-18-34-33.gh-issue-11111.pC7gnM.rst",
8+
"Misc/NEWS.d/next/Core and Builtins/2023-03-17-12-09-45.gh-issue-33333.Pf_BI7.rst",
9+
"Misc/NEWS.d/next/Tools-Demos/2023-03-21-01-27-07.gh-issue-44444.2F1Byz.rst",
10+
"Misc/NEWS.d/next/C API/2023-03-27-22-09-07.gh-issue-66666.3SN8Bs.rst",
11+
)
12+
fake_readmes = (
13+
"Misc/NEWS.d/next/Library/README.rst",
14+
"Misc/NEWS.d/next/Core and Builtins/README.rst",
15+
"Misc/NEWS.d/next/Tools-Demos/README.rst",
16+
"Misc/NEWS.d/next/C API/README.rst",
17+
)
18+
for fn in fake_news_entries + fake_readmes:
19+
fs.create_file(fn)
20+
21+
# Act
22+
filenames = glob_blurbs("next")
23+
24+
# Assert
25+
assert set(filenames) == set(fake_news_entries)
26+
27+
28+
def test_glob_blurbs_sort_order(fs):
29+
"""
30+
It shouldn't make a difference to sorting whether
31+
section names have spaces or underscores.
32+
"""
33+
# Arrange
34+
fake_news_entries = (
35+
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-01-00.gh-issue-33331.Pf_BI1.rst",
36+
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-02-00.gh-issue-33332.Pf_BI2.rst",
37+
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-03-00.gh-issue-33333.Pf_BI3.rst",
38+
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-04-00.gh-issue-33334.Pf_BI4.rst",
39+
)
40+
# As fake_news_entries, but reverse sorted by *filename* only
41+
expected = [
42+
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-04-00.gh-issue-33334.Pf_BI4.rst",
43+
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-03-00.gh-issue-33333.Pf_BI3.rst",
44+
"Misc/NEWS.d/next/Core_and_Builtins/2023-07-23-12-02-00.gh-issue-33332.Pf_BI2.rst",
45+
"Misc/NEWS.d/next/Core and Builtins/2023-07-23-12-01-00.gh-issue-33331.Pf_BI1.rst",
46+
]
47+
fake_readmes = (
48+
"Misc/NEWS.d/next/Library/README.rst",
49+
"Misc/NEWS.d/next/Core and Builtins/README.rst",
50+
"Misc/NEWS.d/next/Tools-Demos/README.rst",
51+
"Misc/NEWS.d/next/C API/README.rst",
52+
)
53+
for fn in fake_news_entries + fake_readmes:
54+
fs.create_file(fn)
55+
56+
# Act
57+
filenames = glob_blurbs("next")
58+
59+
# Assert
60+
assert filenames == expected

tests/test_versions.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import pytest
2+
3+
from blurb._versions import glob_versions, printable_version, version_key
4+
5+
6+
@pytest.mark.parametrize(
7+
"version1, version2",
8+
(
9+
("2", "3"),
10+
("3.5.0a1", "3.5.0b1"),
11+
("3.5.0a1", "3.5.0rc1"),
12+
("3.5.0a1", "3.5.0"),
13+
("3.6.0b1", "3.6.0b2"),
14+
("3.6.0b1", "3.6.0rc1"),
15+
("3.6.0b1", "3.6.0"),
16+
("3.7.0rc1", "3.7.0rc2"),
17+
("3.7.0rc1", "3.7.0"),
18+
("3.8", "3.8.1"),
19+
),
20+
)
21+
def test_version_key(version1, version2):
22+
# Act
23+
key1 = version_key(version1)
24+
key2 = version_key(version2)
25+
26+
# Assert
27+
assert key1 < key2
28+
29+
30+
def test_glob_versions(fs):
31+
# Arrange
32+
fake_version_blurbs = (
33+
"Misc/NEWS.d/3.7.0.rst",
34+
"Misc/NEWS.d/3.7.0a1.rst",
35+
"Misc/NEWS.d/3.7.0a2.rst",
36+
"Misc/NEWS.d/3.7.0b1.rst",
37+
"Misc/NEWS.d/3.7.0b2.rst",
38+
"Misc/NEWS.d/3.7.0rc1.rst",
39+
"Misc/NEWS.d/3.7.0rc2.rst",
40+
"Misc/NEWS.d/3.9.0b1.rst",
41+
"Misc/NEWS.d/3.12.0a1.rst",
42+
)
43+
for fn in fake_version_blurbs:
44+
fs.create_file(fn)
45+
46+
# Act
47+
versions = glob_versions()
48+
49+
# Assert
50+
assert versions == [
51+
"3.12.0a1",
52+
"3.9.0b1",
53+
"3.7.0",
54+
"3.7.0rc2",
55+
"3.7.0rc1",
56+
"3.7.0b2",
57+
"3.7.0b1",
58+
"3.7.0a2",
59+
"3.7.0a1",
60+
]
61+
62+
63+
@pytest.mark.parametrize(
64+
"version, expected",
65+
(
66+
("next", "next"),
67+
("3.12.0a1", "3.12.0 alpha 1"),
68+
("3.12.0b2", "3.12.0 beta 2"),
69+
("3.12.0rc2", "3.12.0 release candidate 2"),
70+
("3.12.0", "3.12.0 final"),
71+
("3.12.1", "3.12.1 final"),
72+
),
73+
)
74+
def test_printable_version(version, expected):
75+
# Act / Assert
76+
assert printable_version(version) == expected

0 commit comments

Comments
 (0)