Skip to content

Commit 246591e

Browse files
authored
Add the "tests" label for files starting with "_test" (#606)
1 parent 21092fb commit 246591e

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

bedevere/prtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async def classify_by_filepaths(gh, pull_request, filenames):
4545
filepath = pathlib.PurePath(filename)
4646
if filepath.suffix == ".rst" or filepath.name == ".nitignore":
4747
docs = True
48-
elif filepath.name.startswith("test_"):
48+
elif filepath.name.startswith(("test_", "_test")):
4949
tests = True
5050
else:
5151
return pr_labels

tests/test_prtype.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,26 @@ async def test_tests_only():
145145
assert gh.post_data[0] == [Labels.tests.value]
146146

147147

148+
async def test_tests_and_testmods_only():
149+
filenames = {"/path/to/_testmod.c", "_test_module.c", "test_capi,py"}
150+
issue = {"labels": [], "labels_url": "https://api.github.com/some/label"}
151+
gh = FakeGH(getitem=issue)
152+
event_data = {
153+
"action": "opened",
154+
"number": 1234,
155+
"pull_request": {
156+
"url": "https://api.github.com/repos/cpython/python/pulls/1234",
157+
"statuses_url": "https://api.github.com/some/status",
158+
"issue_url": "https://api.github.com/repos/cpython/python/issue/1234",
159+
},
160+
}
161+
await prtype.classify_by_filepaths(gh, event_data["pull_request"], filenames)
162+
assert gh.getitem_url == "https://api.github.com/repos/cpython/python/issue/1234"
163+
assert len(gh.post_url) == 1
164+
assert gh.post_url[0] == "https://api.github.com/some/label"
165+
assert gh.post_data[0] == [Labels.tests.value]
166+
167+
148168
async def test_docs_and_tests():
149169
filenames = {"/path/to/docs.rst", "test_docs2.py"}
150170
issue = {

0 commit comments

Comments
 (0)