-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_copier.py
More file actions
134 lines (111 loc) · 5.04 KB
/
test_copier.py
File metadata and controls
134 lines (111 loc) · 5.04 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import pytest
def test_project_folder(default_project):
assert default_project.exit_code == 0
assert default_project.exception is None
assert default_project.project_dir.is_dir()
@pytest.mark.parametrize("file_name", [
"README.md",
"LICENSE",
"CONTRIBUTING.rst",
"pyproject.toml",
"my_project/__init__.py",
"my_project/my_project.py",
".github/ISSUE_TEMPLATE/01-bug-report.yml",
".github/ISSUE_TEMPLATE/02-question.yml",
".github/ISSUE_TEMPLATE/03-feature-request.yml",
".github/ISSUE_TEMPLATE/04-documentation.yml",
])
def test_generated_file_exists(default_project, file_name):
assert default_project.project_dir.joinpath(file_name).exists()
@pytest.mark.parametrize("desired", [
"\nmy_project_description\n",
"pip install my_project",
"https://circleci.com/gh/pyfar/my-project",
"main/docs/resources/logos/pyfar_logos_fixed_size_my_project.png",
"Python 3.11 or higher",
"py/my_project.svg",
"https://my_project.readthedocs.io/en/stable/contributing.html",
"\nThis is how to get started.\n",
])
def test_content_readme(default_project, desired):
content = default_project.project_dir.joinpath("README.md").read_text()
assert desired in content
def test_license_default(default_project):
content = default_project.project_dir.joinpath("LICENSE").read_text()
assert 'Copyright (c) 2025, The pyfar developers' in content
@pytest.mark.parametrize(("license_default", "desired"), [
("MIT", "The MIT License (MIT)"),
("BSD-3-Clause", "Redistribution and use in source and binary forms"),
("Apache-2.0", "Apache License"),
("GPL-3.0-only", "GNU GENERAL PUBLIC LICENSE"),
("EUPL-1.2", "EUROPEAN UNION PUBLIC LICENCE v. 1.2"),
("MPL-2.0", "Mozilla Public License Version 2.0")])
def test_content_license(copie, copier_project_defaults,
license_default, desired):
project = copie.copy(extra_answers={**copier_project_defaults,
"license": license_default})
content = project.project_dir.joinpath("LICENSE").read_text()
assert desired in content
def test_license_choice_other(copie, copier_project_defaults):
project = copie.copy(extra_answers={**copier_project_defaults,
"license": ""})
assert not project.project_dir.joinpath("LICENSE").exists()
@pytest.mark.parametrize("desired", [
"https://github.com/pyfar/my_project/issues",
"$ cd my_project",
])
def test_content_contributing(default_project, desired):
content = default_project.project_dir.joinpath(
"CONTRIBUTING.rst").read_text()
assert desired in content
@pytest.mark.parametrize("desired", [
'name = "my_project"',
'version = "0.1.0"',
'description = "my_project_short_description"',
'requires-python = ">=3.11"',
'\n "acoustics",\n',
'\n "pyfar",\n',
'\n "numpy",\n',
'\n "scipy",\n',
'"License :: OSI Approved :: MIT License"',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
'Tracker = "https://github.com/pyfar/my_project/issues"',
])
def test_content_pyproject(default_project, desired):
content = default_project.project_dir.joinpath(
"pyproject.toml").read_text()
assert desired in content, f"{desired!r} is not in content"
@pytest.mark.parametrize("not_desired", [
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
])
def test_incorrect_content_pyproject(default_project, not_desired):
content = default_project.project_dir.joinpath(
"pyproject.toml").read_text()
assert not_desired not in content, f"{not_desired!r} is in content"
@pytest.mark.parametrize("desired", [
'Top-level package for my_project.',
'__author__ = """The pyfar developers"""',
"__version__ = '0.1.0'",
])
def test_content_project_slug_init(default_project, desired):
content = default_project.project_dir.joinpath('my_project').joinpath(
"__init__.py").read_text()
assert desired in content, f"{desired!r} is not in content"
@pytest.mark.parametrize("file_name", [
".github/ISSUE_TEMPLATE/01-bug-report.yml",
".github/ISSUE_TEMPLATE/02-question.yml",
".github/ISSUE_TEMPLATE/03-feature-request.yml",
])
def test_content_github_issue_template(default_project, file_name):
content = default_project.project_dir.joinpath(file_name).read_text()
desired = 'https://github.com/pyfar/my_project/issues'
assert desired in content, f"{desired!r} is not in content"
def test_content_github_04_documentation(default_project):
content = default_project.project_dir.joinpath(
".github/ISSUE_TEMPLATE/04-documentation.yml").read_text()
desired = 'https://my_project.readthedocs.io/en/develop/.'
assert desired in content, f"{desired!r} is not in content"