1
1
import os
2
-
3
- import py
2
+ from io import StringIO
4
3
5
4
import _pytest ._code
6
5
import pytest
13
12
14
13
def test_write_log_entry ():
15
14
reslog = ResultLog (None , None )
16
- reslog .logfile = py . io . TextIO ()
15
+ reslog .logfile = StringIO ()
17
16
reslog .write_log_entry ("name" , "." , "" )
18
17
entry = reslog .logfile .getvalue ()
19
18
assert entry [- 1 ] == "\n "
20
19
entry_lines = entry .splitlines ()
21
20
assert len (entry_lines ) == 1
22
21
assert entry_lines [0 ] == ". name"
23
22
24
- reslog .logfile = py . io . TextIO ()
23
+ reslog .logfile = StringIO ()
25
24
reslog .write_log_entry ("name" , "s" , "Skipped" )
26
25
entry = reslog .logfile .getvalue ()
27
26
assert entry [- 1 ] == "\n "
@@ -30,7 +29,7 @@ def test_write_log_entry():
30
29
assert entry_lines [0 ] == "s name"
31
30
assert entry_lines [1 ] == " Skipped"
32
31
33
- reslog .logfile = py . io . TextIO ()
32
+ reslog .logfile = StringIO ()
34
33
reslog .write_log_entry ("name" , "s" , "Skipped\n " )
35
34
entry = reslog .logfile .getvalue ()
36
35
assert entry [- 1 ] == "\n "
@@ -39,7 +38,7 @@ def test_write_log_entry():
39
38
assert entry_lines [0 ] == "s name"
40
39
assert entry_lines [1 ] == " Skipped"
41
40
42
- reslog .logfile = py . io . TextIO ()
41
+ reslog .logfile = StringIO ()
43
42
longrepr = " tb1\n tb 2\n E tb3\n Some Error"
44
43
reslog .write_log_entry ("name" , "F" , longrepr )
45
44
entry = reslog .logfile .getvalue ()
@@ -118,7 +117,7 @@ def test_internal_exception(self, style):
118
117
raise ValueError
119
118
except ValueError :
120
119
excinfo = _pytest ._code .ExceptionInfo .from_current ()
121
- reslog = ResultLog (None , py . io . TextIO ())
120
+ reslog = ResultLog (None , StringIO ())
122
121
reslog .pytest_internalerror (excinfo .getrepr (style = style ))
123
122
entry = reslog .logfile .getvalue ()
124
123
entry_lines = entry .splitlines ()
0 commit comments