-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote some unit tests and enabled Travis-CI. (GH-37)
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: python | ||
cache: pip | ||
python: | ||
- 3.6 | ||
- 3.6-dev | ||
- 3.7-dev | ||
- nightly | ||
|
||
install: | ||
- python3 -m pip install -U -r dev-requirements.txt | ||
script: | ||
- python3 -m pytest tests/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-r requirements.txt | ||
pytest~=3.0.7 | ||
pytest-asyncio~=0.5.0 | ||
pytest-aiohttp~=0.1.3 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from unittest import mock | ||
|
||
|
||
from backport import util | ||
|
||
|
||
def test_title_normalization(): | ||
title = "abcd" | ||
body = "1234" | ||
assert util.normalize_title(title, body) == title | ||
|
||
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …" | ||
body = "…(GH-1478)\r\n\r\nstuff" | ||
expected = '[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-1478)' | ||
assert util.normalize_title(title, body) == expected | ||
|
||
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …" | ||
body = "…(GH-1478)" | ||
assert util.normalize_title(title, body) == expected | ||
|
||
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-14…" | ||
body = "…78)" | ||
assert util.normalize_title(title, body) == expected | ||
|
||
|
||
def test_get_participants_different_creator_and_committer(): | ||
assert util.get_participants("miss-islington", "bedevere-bot") \ | ||
== "@miss-islington and @bedevere-bot" | ||
|
||
|
||
def test_get_participants_same_creator_and_committer(): | ||
assert util.get_participants("miss-islington", | ||
"miss-islington") == "@miss-islington" | ||
|
||
|
||
@mock.patch('subprocess.check_output') | ||
def test_is_cpython_repo_contains_first_cpython_commit(subprocess_check_output): | ||
mock_output = b"""commit 7f777ed95a19224294949e1b4ce56bbffcb1fe9f | ||
Author: Guido van Rossum <guido@python.org> | ||
Date: Thu Aug 9 14:25:15 1990 +0000 | ||
Initial revision""" | ||
subprocess_check_output.return_value = mock_output | ||
assert util.is_cpython_repo() | ||
|
||
|
||
def test_is_not_cpython_repo(): | ||
assert util.is_cpython_repo() == False |