Skip to content

Commit

Permalink
Add the "tests" label for files starting with "_test" (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev authored Jan 20, 2024
1 parent 21092fb commit 246591e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bedevere/prtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def classify_by_filepaths(gh, pull_request, filenames):
filepath = pathlib.PurePath(filename)
if filepath.suffix == ".rst" or filepath.name == ".nitignore":
docs = True
elif filepath.name.startswith("test_"):
elif filepath.name.startswith(("test_", "_test")):
tests = True
else:
return pr_labels
Expand Down
20 changes: 20 additions & 0 deletions tests/test_prtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ async def test_tests_only():
assert gh.post_data[0] == [Labels.tests.value]


async def test_tests_and_testmods_only():
filenames = {"/path/to/_testmod.c", "_test_module.c", "test_capi,py"}
issue = {"labels": [], "labels_url": "https://api.github.com/some/label"}
gh = FakeGH(getitem=issue)
event_data = {
"action": "opened",
"number": 1234,
"pull_request": {
"url": "https://api.github.com/repos/cpython/python/pulls/1234",
"statuses_url": "https://api.github.com/some/status",
"issue_url": "https://api.github.com/repos/cpython/python/issue/1234",
},
}
await prtype.classify_by_filepaths(gh, event_data["pull_request"], filenames)
assert gh.getitem_url == "https://api.github.com/repos/cpython/python/issue/1234"
assert len(gh.post_url) == 1
assert gh.post_url[0] == "https://api.github.com/some/label"
assert gh.post_data[0] == [Labels.tests.value]


async def test_docs_and_tests():
filenames = {"/path/to/docs.rst", "test_docs2.py"}
issue = {
Expand Down

0 comments on commit 246591e

Please sign in to comment.