Skip to content

Commit 383d1ee

Browse files
committed
Move to py.test!
Also enforce ordering of tests and test files, given nodeids for generators depend upon iteration number, and pytest-expect relies on them.
1 parent 71ac558 commit 383d1ee

File tree

8 files changed

+16
-12
lines changed

8 files changed

+16
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ install:
3838
- bash requirements-install.sh
3939

4040
script:
41-
- nosetests
41+
- py.test
4242
- bash flake8-run.sh
4343

4444
after_script:

README.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ Please report any bugs on the `issue tracker
132132
Tests
133133
-----
134134

135-
Unit tests require the ``nose`` and ``mock`` libraries and can be run
136-
using the ``nosetests`` command in the root directory; ``ordereddict``
137-
is required under Python 2.6. All should pass.
135+
Unit tests require the ``pytest`` and ``mock`` libraries and can be
136+
run using the ``py.test`` command in the root directory;
137+
``ordereddict`` is required under Python 2.6. All should pass.
138138

139139
Test data are contained in a separate `html5lib-tests
140140
<https://github.com/html5lib/html5lib-tests>`_ repository and included

html5lib/tests/support.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
def get_data_files(subdirectory, files='*.dat'):
45-
return glob.glob(os.path.join(test_dir, subdirectory, files))
45+
return sorted(glob.glob(os.path.join(test_dir, subdirectory, files)))
4646

4747

4848
class DefaultDict(dict):

html5lib/tests/test_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_parser():
9090
if errors:
9191
errors = errors.split("\n")
9292

93-
for treeName, treeCls in treeTypes.items():
93+
for treeName, treeCls in sorted(treeTypes.items()):
9494
for namespaceHTMLElements in (True, False):
9595
yield (runParserTest, innerHTML, input, expected, errors, treeCls,
9696
namespaceHTMLElements)

html5lib/tests/test_treewalkers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_all_tokens(self):
8787
{'data': {}, 'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'body'},
8888
{'data': {}, 'type': 'EndTag', 'namespace': 'http://www.w3.org/1999/xhtml', 'name': 'html'}
8989
]
90-
for treeName, treeCls in treeTypes.items():
90+
for treeName, treeCls in sorted(treeTypes.items()):
9191
p = html5parser.HTMLParser(tree=treeCls["builder"])
9292
document = p.parse("<html><head></head><body>a<div>b</div>c</body></html>")
9393
document = treeCls.get("adapter", lambda x: x)(document)
@@ -130,7 +130,7 @@ def runTreewalkerTest(innerHTML, input, expected, errors, treeClass):
130130
def test_treewalker():
131131
sys.stdout.write('Testing tree walkers ' + " ".join(list(treeTypes.keys())) + "\n")
132132

133-
for treeName, treeCls in treeTypes.items():
133+
for treeName, treeCls in sorted(treeTypes.items()):
134134
files = get_data_files('tree-construction')
135135
for filename in files:
136136
testName = os.path.basename(filename).replace(".dat", "")
@@ -194,6 +194,6 @@ def test_treewalker_six_mix():
194194
'<link>\n href="http://example.com/cow"\n rel="alternate"\n "Example"')
195195
]
196196

197-
for tree in treeTypes.items():
197+
for tree in sorted(treeTypes.items()):
198198
for intext, attrs, expected in sm_tests:
199199
yield runTreewalkerEditTest, intext, expected, attrs, tree

pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = -rXw -p no:doctest

requirements-test.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-r requirements.txt
22

33
flake8
4-
nose
4+
pytest
5+
pytest-expect>=1.0,<2.0
56
mock
67
ordereddict ; python_version < '2.7'

tox.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ envlist = {py26,py27,py32,py33,py34,py35,pypy,pypy3}-{base,optional}
44
[testenv]
55
deps =
66
flake8
7-
nose
7+
pytest
8+
pytest-expect>=1.0,<2.0
89
mock
910
py26-base: ordereddict
1011
optional: -r{toxinidir}/requirements-optional.txt
1112

1213
commands =
13-
{envbindir}/nosetests -q
14+
{envbindir}/py.test
1415
{toxinidir}/flake8-run.sh

0 commit comments

Comments
 (0)