Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9b1a9f

Browse files
committed
sys.version_info is only a "named tuple"-like obj from 2.7
This also adds the mock package as a dependency for the testsuite,as we need it to test our test code.
1 parent92c2e32 commitd9b1a9f

File tree

7 files changed

+53
-5
lines changed

7 files changed

+53
-5
lines changed

‎CHANGES.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ Change Log
77
Released on XXX
88

99
* Added ordereddict as a mandatory dependency on Python 2.6.
10+
1011
* Added ``lxml``, ``genshi``, ``datrie``, ``charade``, and ``all`` extras that
1112
will do the right thing based on the specific interpreter implementation.
1213

14+
* Now requires the ``mock`` package for the testsuite.
15+
1316

1417
0.9999999/1.0b8
1518
~~~~~~~~~~~~~~~

‎README.rst‎

Lines changed: 3 additions & 3 deletions
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``libraryand can be run using the
136-
``nosetests`` command in the root directory; ``ordereddict`` is
137-
required under Python 2.6. All should pass.
135+
Unit tests require the ``nose``and ``mock`` librariesand can be run
136+
using the``nosetests`` command in the root directory; ``ordereddict``
137+
isrequired 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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def convertData(data):
128128
deferrorMessage(input,expected,actual):
129129
msg= ("Input:\n%s\nExpected:\n%s\nRecieved\n%s\n"%
130130
(repr(input),repr(expected),repr(actual)))
131-
ifsys.version_info.major==2:
131+
ifsys.version_info[0]==2:
132132
msg=msg.encode("ascii","backslashreplace")
133133
returnmsg
134134

‎html5lib/tests/test_meta.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__importabsolute_import,division,unicode_literals
2+
3+
importsix
4+
frommockimportMock
5+
6+
from .importsupport
7+
8+
9+
def_createReprMock(r):
10+
"""Creates a mock with a __repr__ returning r
11+
12+
Also provides __str__ mock with default mock behaviour"""
13+
mock=Mock()
14+
mock.__repr__=Mock()
15+
mock.__repr__.return_value=r
16+
mock.__str__=Mock(wraps=mock.__str__)
17+
returnmock
18+
19+
20+
deftest_errorMessage():
21+
# Create mock objects to take repr of
22+
input=_createReprMock("1")
23+
expected=_createReprMock("2")
24+
actual=_createReprMock("3")
25+
26+
# Run the actual test
27+
r=support.errorMessage(input,expected,actual)
28+
29+
# Assertions!
30+
ifsix.PY2:
31+
assertb"Input:\n1\nExpected:\n2\nRecieved\n3\n"==r
32+
else:
33+
assertsix.PY3
34+
assert"Input:\n1\nExpected:\n2\nRecieved\n3\n"==r
35+
36+
assertinput.__repr__.call_count==1
37+
assertexpected.__repr__.call_count==1
38+
assertactual.__repr__.call_count==1
39+
assertnotinput.__str__.called
40+
assertnotexpected.__str__.called
41+
assertnotactual.__str__.called

‎html5lib/treebuilders/etree_lxml.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def serializeElement(element, indent=0):
7979
next_element=next_element.getnext()
8080
elifisinstance(element,str)orisinstance(element,bytes):
8181
# Text in a fragment
82-
assertisinstance(element,str)orsys.version_info.major==2
82+
assertisinstance(element,str)orsys.version_info[0]==2
8383
rv.append("|%s\"%s\""% (' '*indent,element))
8484
else:
8585
# Fragment case

‎requirements-test.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
flake8
44
nose
55
ordereddict # Python 2.6
6+
mock

‎tox.ini‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ deps =
66
-r{toxinidir}/requirements-optional-cpython.txt
77
flake8
88
nose
9+
mock
910
commands =
1011
{envbindir}/nosetests -q
1112
{toxinidir}/flake8-run.sh
@@ -21,10 +22,12 @@ deps =
2122
Genshi
2223
nose
2324
six
25+
mock
2426

2527
[testenv:py26]
2628
basepython = python2.6
2729
deps =
2830
-r{toxinidir}/requirements-optional-2.6.txt
2931
flake8
3032
nose
33+
mock

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp