Skip to content

Commit 069db1c

Browse files
Talha MalikTalha Malik
Talha Malik
authored and
Talha Malik
committed
Text stdin without mock
1 parent e63b269 commit 069db1c

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

jsonschema/tests/test_cli.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
from unittest import TestCase
2-
3-
try:
4-
from unittest import mock
5-
except ImportError:
6-
from mock import mock
7-
82
import json
93
import subprocess
104
import sys
115

6+
try:
7+
from StringIO import StringIO
8+
except ImportError:
9+
from io import StringIO
10+
1211
from jsonschema import Draft4Validator, ValidationError, cli, __version__
1312
from jsonschema.compat import NativeIO
1413
from jsonschema.exceptions import SchemaError
@@ -156,9 +155,8 @@ def test_version(self):
156155
version = version.decode("utf-8").strip()
157156
self.assertEqual(version, __version__)
158157

159-
@mock.patch("sys.stdin")
160-
def test_piping(self, mock_stdin):
161-
mock_stdin.read.return_value = "{}"
158+
def test_piping(self):
159+
sys.stdin = StringIO("{}")
162160
stdout, stderr = NativeIO(), NativeIO()
163161
exit_code = cli.run(
164162
{
@@ -170,7 +168,6 @@ def test_piping(self, mock_stdin):
170168
stdout=stdout,
171169
stderr=stderr,
172170
)
173-
mock_stdin.read.assert_called_once_with()
174171
self.assertFalse(stdout.getvalue())
175172
self.assertFalse(stderr.getvalue())
176173
self.assertEqual(exit_code, 0)

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ deps =
5555
perf: pyperf
5656

5757
tests,tests_nongpl,coverage,codecov: -r{toxinidir}/test-requirements.txt
58-
pypy: mock
5958

6059
coverage,codecov: coverage
6160
codecov: codecov

0 commit comments

Comments
 (0)