Skip to content

Commit 2d19d52

Browse files
authored
Merge pull request #68 from redapple/doctest-tox-pytest
Run doctests with tox (and py.test)
2 parents ad212c0 + d851bea commit 2d19d52

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

conftest.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
import six
2-
collect_ignore = []
3-
4-
if six.PY3:
5-
for fn in open('tests/py3-ignores.txt'):
6-
if fn.strip():
7-
collect_ignore.append(fn.strip())
1+
collect_ignore = ["setup.py"]

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
doctest_optionflags = ALLOW_UNICODE ALLOW_BYTES

tox.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ deps =
1111
pytest
1212
pytest-cov
1313
commands =
14-
py.test --cov=w3lib --cov-report= {posargs:w3lib tests}
14+
py.test \
15+
--doctest-modules \
16+
--cov=w3lib --cov-report=term \
17+
{posargs:w3lib tests}

w3lib/encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def html_to_unicode(content_type_header, html_body_str,
230230
231231
>>> import w3lib.encoding
232232
>>> w3lib.encoding.html_to_unicode(None,
233-
... """<!DOCTYPE html>
233+
... b"""<!DOCTYPE html>
234234
... <head>
235235
... <meta charset="UTF-8" />
236236
... <meta name="viewport" content="width=device-width" />

w3lib/url.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def urljoin_rfc(base, ref, encoding='utf-8'):
3535
.. warning::
3636
3737
This function is deprecated and will be removed in future.
38+
It is not supported with Python 3.
3839
Please use ``urlparse.urljoin`` instead.
3940
4041
Same as urlparse.urljoin but supports unicode values in base and ref
@@ -48,7 +49,8 @@ def urljoin_rfc(base, ref, encoding='utf-8'):
4849
'http://www.example.com/otherpath/index2.html'
4950
>>>
5051
51-
>>> w3lib.url.urljoin_rfc('http://www.example.com/path/index.html', u'fran\u00e7ais/d\u00e9part.htm')
52+
>>> # Note: the following does not work in Python 3
53+
>>> w3lib.url.urljoin_rfc(b'http://www.example.com/path/index.html', u'fran\u00e7ais/d\u00e9part.htm') # doctest: +SKIP
5254
'http://www.example.com/path/fran\xc3\xa7ais/d\xc3\xa9part.htm'
5355
>>>
5456

0 commit comments

Comments
 (0)