@@ -32,10 +32,8 @@ class A(object):
32
32
pytest .raises (TypeError , "_pytest._code.Code(A)" )
33
33
34
34
35
- if True :
36
-
37
- def x ():
38
- pass
35
+ def x ():
36
+ raise NotImplementedError ()
39
37
40
38
41
39
def test_code_fullsource ():
@@ -48,7 +46,7 @@ def test_code_source():
48
46
code = _pytest ._code .Code (x )
49
47
src = code .source ()
50
48
expected = """def x():
51
- pass """
49
+ raise NotImplementedError() """
52
50
assert str (src ) == expected
53
51
54
52
@@ -85,9 +83,9 @@ def f():
85
83
raise Exception (value )
86
84
87
85
excinfo = pytest .raises (Exception , f )
88
- str (excinfo )
89
- if sys .version_info [ 0 ] < 3 :
90
- text_type (excinfo )
86
+ text_type (excinfo )
87
+ if sys .version_info < ( 3 ,) :
88
+ bytes (excinfo )
91
89
92
90
93
91
@pytest .mark .skipif (sys .version_info [0 ] >= 3 , reason = "python 2 only issue" )
@@ -105,25 +103,25 @@ def f():
105
103
106
104
def test_code_getargs ():
107
105
def f1 (x ):
108
- pass
106
+ raise NotImplementedError ()
109
107
110
108
c1 = _pytest ._code .Code (f1 )
111
109
assert c1 .getargs (var = True ) == ("x" ,)
112
110
113
111
def f2 (x , * y ):
114
- pass
112
+ raise NotImplementedError ()
115
113
116
114
c2 = _pytest ._code .Code (f2 )
117
115
assert c2 .getargs (var = True ) == ("x" , "y" )
118
116
119
117
def f3 (x , ** z ):
120
- pass
118
+ raise NotImplementedError ()
121
119
122
120
c3 = _pytest ._code .Code (f3 )
123
121
assert c3 .getargs (var = True ) == ("x" , "z" )
124
122
125
123
def f4 (x , * y , ** z ):
126
- pass
124
+ raise NotImplementedError ()
127
125
128
126
c4 = _pytest ._code .Code (f4 )
129
127
assert c4 .getargs (var = True ) == ("x" , "y" , "z" )
@@ -188,11 +186,14 @@ def test_not_raise_exception_with_mixed_encoding(self):
188
186
189
187
tw = TWMock ()
190
188
191
- args = [("unicode_string" , u"São Paulo" ), ("utf8_string" , "S\xc3 \xa3 o Paulo" )]
189
+ args = [("unicode_string" , u"São Paulo" ), ("utf8_string" , b "S\xc3 \xa3 o Paulo" )]
192
190
193
191
r = ReprFuncArgs (args )
194
192
r .toterminal (tw )
195
193
if sys .version_info [0 ] >= 3 :
196
- assert tw .lines [0 ] == "unicode_string = São Paulo, utf8_string = São Paulo"
194
+ assert (
195
+ tw .lines [0 ]
196
+ == r"unicode_string = São Paulo, utf8_string = b'S\xc3\xa3o Paulo'"
197
+ )
197
198
else :
198
199
assert tw .lines [0 ] == "unicode_string = São Paulo, utf8_string = São Paulo"
0 commit comments