4
4
from whatthepatch import exceptions
5
5
from whatthepatch .snippets import which
6
6
7
- from nose . tools import assert_raises
7
+ import pytest
8
8
import unittest
9
9
from unittest .case import SkipTest
10
10
@@ -26,7 +26,7 @@ def setUp(self):
26
26
self .lao = f .read ().splitlines ()
27
27
28
28
with open ("tests/casefiles/tzu" ) as f :
29
- self .tzu = f .read ().splitlines ()
29
+ self .tzu = f .read ().splitlines ()
30
30
31
31
def test_truth (self ):
32
32
self .assertEqual (type (self .lao ), list )
@@ -59,10 +59,10 @@ def test_diff_unified_bad(self):
59
59
with open ("tests/casefiles/diff-unified-bad.diff" ) as f :
60
60
diff_text = f .read ()
61
61
62
- with assert_raises (exceptions .ApplyException ) as ec :
62
+ with pytest . raises (exceptions .ApplyException ) as ec :
63
63
_apply (self .lao , diff_text )
64
64
65
- e = ec .exception
65
+ e = ec .value
66
66
e_str = str (e )
67
67
assert "line 4" in e_str
68
68
assert "The Named is the mother of all tings." in e_str
@@ -73,10 +73,10 @@ def test_diff_unified_bad2(self):
73
73
with open ("tests/casefiles/diff-unified-bad2.diff" ) as f :
74
74
diff_text = f .read ()
75
75
76
- with assert_raises (exceptions .ApplyException ) as ec :
76
+ with pytest . raises (exceptions .ApplyException ) as ec :
77
77
_apply (self .lao , diff_text )
78
78
79
- e = ec .exception
79
+ e = ec .value
80
80
e_str = str (e )
81
81
assert "line 9" in e_str
82
82
assert "The two are te same," in e_str
@@ -87,10 +87,10 @@ def test_diff_unified_bad_backward(self):
87
87
with open ("tests/casefiles/diff-unified-bad2.diff" ) as f :
88
88
diff_text = f .read ()
89
89
90
- with assert_raises (exceptions .ApplyException ) as ec :
90
+ with pytest . raises (exceptions .ApplyException ) as ec :
91
91
_apply (self .tzu , diff_text )
92
92
93
- e = ec .exception
93
+ e = ec .value
94
94
e_str = str (e )
95
95
assert "line 1" in e_str
96
96
assert "The Way that can be told of is not the eternal Way;" in e_str
@@ -101,10 +101,10 @@ def test_diff_unified_bad_empty_source(self):
101
101
with open ("tests/casefiles/diff-unified-bad2.diff" ) as f :
102
102
diff_text = f .read ()
103
103
104
- with assert_raises (exceptions .ApplyException ) as ec :
104
+ with pytest . raises (exceptions .ApplyException ) as ec :
105
105
_apply ("" , diff_text )
106
106
107
- e = ec .exception
107
+ e = ec .value
108
108
e_str = str (e )
109
109
assert "line 1" in e_str
110
110
assert "The Way that can be told of is not the eternal Way;" in e_str
@@ -126,7 +126,7 @@ def test_diff_unified_patchutil(self):
126
126
new_text = _apply (self .lao , diff_text , use_patch = True )
127
127
self .assertEqual (new_text , (self .tzu , None ))
128
128
129
- with assert_raises (exceptions .ApplyException ):
129
+ with pytest . raises (exceptions .ApplyException ):
130
130
_apply (["" ] + self .lao , diff_text , use_patch = True )
131
131
132
132
def test_diff_rcs (self ):
0 commit comments