Skip to content

Commit 99e877e

Browse files
committed
Use pytest for tests & fix issue for URLs with usernames
1 parent 741d1f8 commit 99e877e

9 files changed

Lines changed: 757 additions & 627 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/venv
33
/src
44
/build
5-
*.so
5+
*.so
6+
/.cache

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ benchmark:
55
python benchmarks/urls.py
66

77
test:
8-
python tests/test_*.py
8+
py.test tests/ -v
99

1010
docker_build:
1111
docker build -t commonsearch/urlparse4 .

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
tabulate==0.7.5
22
Cython==0.24
3+
pytest==2.9.2
34

45
# For benchmarks
56
uritools==1.0.2

tests/test_urlparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ def test_portseparator(self):
630630
self.assertEqual(urlparse.urlparse("http://www.python.org:80"),
631631
('http','www.python.org:80','','','',''))
632632

633-
def test_main():
634-
test_support.run_unittest(UrlParseTestCase)
633+
# def test_main():
634+
# test_support.run_unittest(UrlParseTestCase)
635635

636-
if __name__ == "__main__":
637-
test_main()
636+
# if __name__ == "__main__":
637+
# test_main()

tests/test_urlparse4.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# https://github.com/python/cpython/blob/40dac3272231773af0015fc35df5353783d77c4e/Lib/test/test_urlparse.py
2+
import sys
3+
import os
4+
sys.path.insert(-1, os.path.dirname(os.path.dirname(__file__)))
5+
6+
from test import test_support
7+
import unittest
8+
import urlparse4 as urlparse
9+
10+
11+
urlsplit_testcases = [
12+
["mailto:webtechs@oltn.odl.state.ok.us", ("mailto", "webtechs@oltn.odl.state.ok.us", "", "", "")],
13+
["mailto:mailto:webtechs@oltn.odl.state.ok.us", ("mailto", "mailto:webtechs@oltn.odl.state.ok.us", "", "", "")],
14+
["http://a@example.com:80", ("http", "a@example.com:80", "", "", "")],
15+
16+
]
17+
18+
19+
class UrlParse4TestCase(unittest.TestCase):
20+
21+
def test_urlsplit(self):
22+
for case in urlsplit_testcases:
23+
self.assertEqual(urlparse.urlsplit(case[0]), case[1])

0 commit comments

Comments
 (0)