forked from html5lib/html5lib-python
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
7 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from __future__ import absolute_import, division, unicode_literals | ||
|
||
import six | ||
from mock import Mock | ||
|
||
from . import support | ||
|
||
|
||
def _createReprMock(r): | ||
"""Creates a mock with a __repr__ returning r | ||
Also provides __str__ mock with default mock behaviour""" | ||
mock = Mock() | ||
mock.__repr__ = Mock() | ||
mock.__repr__.return_value = r | ||
mock.__str__ = Mock(wraps=mock.__str__) | ||
return mock | ||
|
||
|
||
def test_errorMessage(): | ||
# Create mock objects to take repr of | ||
input = _createReprMock("1") | ||
expected = _createReprMock("2") | ||
actual = _createReprMock("3") | ||
|
||
# Run the actual test | ||
r = support.errorMessage(input, expected, actual) | ||
|
||
# Assertions! | ||
if six.PY2: | ||
assert b"Input:\n1\nExpected:\n2\nRecieved\n3\n" == r | ||
else: | ||
assert six.PY3 | ||
assert "Input:\n1\nExpected:\n2\nRecieved\n3\n" == r | ||
|
||
assert input.__repr__.call_count == 1 | ||
assert expected.__repr__.call_count == 1 | ||
assert actual.__repr__.call_count == 1 | ||
assert not input.__str__.called | ||
assert not expected.__str__.called | ||
assert not actual.__str__.called |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
flake8 | ||
nose | ||
ordereddict # Python 2.6 | ||
mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters