Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ac8fbd

Browse files
authored
Wrote some unit tests and enabled Travis-CI. (GH-37)
1 parent 2867c42 commit 8ac8fbd

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: python
2+
cache: pip
3+
python:
4+
- 3.6
5+
- 3.6-dev
6+
- 3.7-dev
7+
- nightly
8+
9+
install:
10+
- python3 -m pip install -U -r dev-requirements.txt
11+
script:
12+
- python3 -m pytest tests/
13+

dev-requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r requirements.txt
2+
pytest~=3.0.7
3+
pytest-asyncio~=0.5.0
4+
pytest-aiohttp~=0.1.3

tests/__init__.py

Whitespace-only changes.

tests/test_util.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from unittest import mock
2+
3+
4+
from backport import util
5+
6+
7+
def test_title_normalization():
8+
title = "abcd"
9+
body = "1234"
10+
assert util.normalize_title(title, body) == title
11+
12+
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …"
13+
body = "…(GH-1478)\r\n\r\nstuff"
14+
expected = '[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-1478)'
15+
assert util.normalize_title(title, body) == expected
16+
17+
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …"
18+
body = "…(GH-1478)"
19+
assert util.normalize_title(title, body) == expected
20+
21+
title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-14…"
22+
body = "…78)"
23+
assert util.normalize_title(title, body) == expected
24+
25+
26+
def test_get_participants_different_creator_and_committer():
27+
assert util.get_participants("miss-islington", "bedevere-bot") \
28+
== "@miss-islington and @bedevere-bot"
29+
30+
31+
def test_get_participants_same_creator_and_committer():
32+
assert util.get_participants("miss-islington",
33+
"miss-islington") == "@miss-islington"
34+
35+
36+
@mock.patch('subprocess.check_output')
37+
def test_is_cpython_repo_contains_first_cpython_commit(subprocess_check_output):
38+
mock_output = b"""commit 7f777ed95a19224294949e1b4ce56bbffcb1fe9f
39+
Author: Guido van Rossum <[email protected]>
40+
Date: Thu Aug 9 14:25:15 1990 +0000
41+
42+
Initial revision"""
43+
subprocess_check_output.return_value = mock_output
44+
assert util.is_cpython_repo()
45+
46+
47+
def test_is_not_cpython_repo():
48+
assert util.is_cpython_repo() == False

0 commit comments

Comments
 (0)