forked from ConorFWild/ligand_neighbourhood_alignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_boilerplate_removed.py
58 lines (45 loc) · 1.69 KB
/
test_boilerplate_removed.py
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
"""
This file checks that all the example boilerplate text has been removed.
It can be deleted when all the contained tests pass
"""
from importlib.metadata import metadata
from pathlib import Path
ROOT = Path(__file__).parent.parent
def skeleton_check(check: bool, text: str):
if ROOT.name == "python3-pip-skeleton" or str(ROOT) == "/project":
# In the skeleton module the check should fail
check = not check
text = f"Skeleton didn't raise: {text}"
if check:
raise AssertionError(text)
def assert_not_contains_text(path: str, text: str, explanation: str):
full_path = ROOT / path
if full_path.exists():
contents = full_path.read_text().replace("\n", " ")
skeleton_check(text in contents, f"Please change ./{path} {explanation}")
# pyproject.toml
def test_module_summary():
summary = metadata("python3-pip-skeleton")["summary"]
skeleton_check(
"One line description of your module" in summary,
"Please change project.description in ./pyproject.toml " "to be a one line description of your module",
)
# README
def test_changed_README_intro():
assert_not_contains_text(
"README.rst",
"This is where you should write a short paragraph",
"to include an intro on what your module does",
)
def test_removed_adopt_skeleton():
assert_not_contains_text(
"README.rst",
"This project contains template code only",
"remove the note at the start",
)
def test_changed_README_body():
assert_not_contains_text(
"README.rst",
"This is where you should put some images or code snippets",
"to include some features and why people should use it",
)