Skip to content

Commit 055d412

Browse files
best place for test
1 parent 52c58a4 commit 055d412

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

tests/python/test_objects.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pythonmonkey as pm
22
import sys
3-
from io import StringIO
43

54

65
def test_eval_pyobjects():
@@ -171,15 +170,4 @@ def test_toPrimitive_stdin():
171170

172171
def test_constructor_stdin():
173172
constructor = pm.eval("(obj) => { return obj.constructor; }")(sys.stdin)
174-
assert repr(constructor).__contains__("<pythonmonkey.JSFunctionProxy object at")
175-
176-
177-
def test_iterable_attribute_console_printing():
178-
temp_out = StringIO()
179-
sys.stdout = temp_out
180-
obj = {}
181-
obj['stdin'] = sys.stdin # sys.stdin is iterable
182-
assert hasattr(sys.stdin, '__iter__') == True
183-
obj['stdin'].isTTY = sys.stdin.isatty()
184-
pm.eval('''(function iife(obj){console.log(obj['stdin'].isTTY);})''')(obj)
185-
assert temp_out.getvalue() == "\x1b[33mfalse\x1b[39m\n"
173+
assert repr(constructor).__contains__("<pythonmonkey.JSFunctionProxy object at")

tests/python/test_pythonmonkey_eval.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,14 @@ def test_console_array():
440440
items = [1, 2, 3]
441441
pm.eval('console.log')(items)
442442
assert temp_out.getvalue() == "[ \x1b[33m1\x1b[39m, \x1b[33m2\x1b[39m, \x1b[33m3\x1b[39m ]\n"
443+
444+
445+
def test_iterable_attribute_console_printing():
446+
temp_out = StringIO()
447+
sys.stdout = temp_out
448+
obj = {}
449+
obj['stdin'] = sys.stdin # sys.stdin is iterable
450+
assert hasattr(sys.stdin, '__iter__') == True
451+
obj['stdin'].isTTY = sys.stdin.isatty()
452+
pm.eval('''(function iife(obj){console.log(obj['stdin'].isTTY);})''')(obj)
453+
assert temp_out.getvalue() == "\x1b[33mfalse\x1b[39m\n"

0 commit comments

Comments
 (0)