forked from python/release-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_update_version_next.py
More file actions
74 lines (46 loc) · 1.52 KB
/
test_update_version_next.py
File metadata and controls
74 lines (46 loc) · 1.52 KB
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
"""Tests for the update_version_next tool."""
from pathlib import Path
import update_version_next
TO_CHANGE = """
Directives to change
--------------------
Here, all occurrences of NEXT (lowercase) should be changed:
.. versionadded:: next
.. versionchanged:: next
.. deprecated:: next
.. deprecated-removed:: next 4.0
whitespace:
.. versionchanged:: next
.. versionchanged :: next
.. versionadded:: next
arguments:
.. versionadded:: next
Foo bar
.. versionadded:: next as ``previousname``
"""
UNCHANGED = """
Unchanged
---------
Here, the word "next" should NOT be changed:
.. versionchanged:: NEXT
..versionchanged:: NEXT
... versionchanged:: next
foo .. versionchanged:: next
.. otherdirective:: next
.. VERSIONCHANGED: next
.. deprecated-removed: 3.0 next
"""
EXPECTED_CHANGED = TO_CHANGE.replace("next", "VER")
def test_freeze_simple_script(tmp_path: Path) -> None:
p = tmp_path.joinpath
p("source.rst").write_text(TO_CHANGE + UNCHANGED)
p("subdir").mkdir()
p("subdir/change.rst").write_text(".. versionadded:: next")
p("subdir/keep.not-rst").write_text(".. versionadded:: next")
p("subdir/keep.rst").write_text("nothing to see here")
args = ["VER", str(tmp_path)]
update_version_next.main(args)
assert p("source.rst").read_text() == EXPECTED_CHANGED + UNCHANGED
assert p("subdir/change.rst").read_text() == ".. versionadded:: VER"
assert p("subdir/keep.not-rst").read_text() == ".. versionadded:: next"
assert p("subdir/keep.rst").read_text() == "nothing to see here"