6
6
import pytest
7
7
8
8
from nose2pytest .script import NoseConversionRefactoringTool
9
-
9
+ from nose2pytest . assert_tools import _supported_nose_name
10
10
11
11
log = logging .getLogger ('nose2pytest' )
12
12
@@ -25,7 +25,7 @@ def setup_log():
25
25
26
26
import nose .tools
27
27
for name , val in vars (nose .tools ).items ():
28
- if name . startswith ( 'assert_' ):
28
+ if _supported_nose_name ( name ):
29
29
nosetools [name ] = val
30
30
31
31
import re , collections
@@ -61,12 +61,14 @@ def test_params(self):
61
61
log.print("hi")
62
62
63
63
assert_true(a)
64
+ ok_(a)
64
65
assert_true(a, 'text')
65
66
assert_true(a, msg='text')
66
67
"""
67
68
check_transformation (test_script , """
68
69
log.print("hi")
69
70
71
+ assert a
70
72
assert a
71
73
assert a, 'text'
72
74
assert a, 'text'
@@ -82,6 +84,9 @@ def test_same_results(self):
82
84
check_passes (refac , 'assert_true(True)' , 'assert True' )
83
85
check_fails (refac , 'assert_true(False)' , 'assert False' )
84
86
87
+ check_passes (refac , 'ok_(True)' , 'assert True' )
88
+ check_fails (refac , 'ok_(False)' , 'assert False' )
89
+
85
90
check_passes (refac , 'assert_false(False)' , 'assert not False' )
86
91
check_fails (refac , 'assert_false(True)' , 'assert not True' )
87
92
@@ -137,6 +142,8 @@ def test_add_parens(self):
137
142
'assert (d < e) in d' )
138
143
check_transformation ('assert_in(d > e, d)' ,
139
144
'assert (d > e) in d' )
145
+ check_transformation ('eq_(a in b, c)' ,
146
+ 'assert (a in b) == c' )
140
147
check_transformation ('assert_equal(a in b, c)' ,
141
148
'assert (a in b) == c' )
142
149
check_transformation ('assert_equal(a not in b, c)' ,
@@ -211,6 +218,8 @@ def test_same_results(self):
211
218
check_fails (refac , 'assert_equal(123, 456)' , 'assert 123 == 456' )
212
219
check_passes (refac , 'assert_equals(123, 123)' , 'assert 123 == 123' )
213
220
check_fails (refac , 'assert_equals(123, 456)' , 'assert 123 == 456' )
221
+ check_passes (refac , 'eq_(123, 123)' , 'assert 123 == 123' )
222
+ check_fails (refac , 'eq_(123, 456)' , 'assert 123 == 456' )
214
223
215
224
check_passes (refac , 'assert_not_equal(123, 456)' , 'assert 123 != 456' )
216
225
check_fails (refac , 'assert_not_equal(123, 123)' , 'assert 123 != 123' )
0 commit comments