1 diff --git a/tests/test_inputs.py b/tests/test_inputs.py
2 index 7c30d45..645b728 100644
3 --- a/tests/test_inputs.py
4 +++ b/tests/test_inputs.py
5 @@ -5,6 +5,7 @@ import re
7 #noinspection PyUnresolvedReferences
11 from flask_restful import inputs
13 @@ -17,7 +18,7 @@ def test_reverse_rfc822_datetime():
16 for date_string, expected in dates:
17 - yield assert_equal, inputs.datetime_from_rfc822(date_string), expected
18 + assert inputs.datetime_from_rfc822(date_string) == expected
21 def test_reverse_iso8601_datetime():
22 @@ -29,7 +30,7 @@ def test_reverse_iso8601_datetime():
25 for date_string, expected in dates:
26 - yield assert_equal, inputs.datetime_from_iso8601(date_string), expected
27 + assert inputs.datetime_from_iso8601(date_string) == expected
31 @@ -53,7 +54,7 @@ def test_urls():
35 - yield assert_equal, inputs.url(value), value
36 + assert inputs.url(value) == value
39 def check_bad_url_raises(value):
40 @@ -118,7 +119,8 @@ def test_regex_bad_input():
41 num_only = inputs.regex(r'^[0-9]+$')
44 - yield assert_raises, ValueError, lambda: num_only(value)
45 + with pytest.raises(ValueError):
49 def test_regex_good_input():
50 @@ -131,12 +133,13 @@ def test_regex_good_input():
51 num_only = inputs.regex(r'^[0-9]+$')
54 - yield assert_equal, num_only(value), value
55 + assert num_only(value) == value
58 def test_regex_bad_pattern():
59 """Regex error raised immediately when regex input parser is created."""
60 - assert_raises(re.error, inputs.regex, '[')
61 + with pytest.raises(re.error):
65 def test_regex_flags_good_input():
66 @@ -149,7 +152,7 @@ def test_regex_flags_good_input():
67 case_insensitive = inputs.regex(r'^[A-Z]+$', re.IGNORECASE)
70 - yield assert_equal, case_insensitive(value), value
71 + assert case_insensitive(value) == value
74 def test_regex_flags_bad_input():
75 @@ -161,7 +164,8 @@ def test_regex_flags_bad_input():
76 case_sensitive = inputs.regex(r'^[A-Z]+$')
79 - yield assert_raises, ValueError, lambda: case_sensitive(value)
80 + with pytest.raises(ValueError):
81 + case_sensitive(value)
84 class TypesTestCase(unittest.TestCase):
85 @@ -191,35 +195,41 @@ class TypesTestCase(unittest.TestCase):
86 assert inputs.boolean(False) == False
88 def test_bad_boolean(self):
89 - assert_raises(ValueError, lambda: inputs.boolean("blah"))
90 + with pytest.raises(ValueError):
91 + inputs.boolean("blah")
93 def test_date_later_than_1900(self):
94 assert inputs.date("1900-01-01") == datetime(1900, 1, 1)
96 def test_date_input_error(self):
97 - assert_raises(ValueError, lambda: inputs.date("2008-13-13"))
98 + with pytest.raises(ValueError):
99 + inputs.date("2008-13-13")
101 def test_date_input(self):
102 assert inputs.date("2008-08-01") == datetime(2008, 8, 1)
104 def test_natual_negative(self):
105 - assert_raises(ValueError, lambda: inputs.natural(-1))
106 + with pytest.raises(ValueError):
109 def test_natural(self):
110 assert 3 == inputs.natural(3)
112 def test_natual_string(self):
113 - assert_raises(ValueError, lambda: inputs.natural('foo'))
114 + with pytest.raises(ValueError):
115 + inputs.natural('foo')
117 def test_positive(self):
118 assert 1 == inputs.positive(1)
119 assert 10000 == inputs.positive(10000)
121 def test_positive_zero(self):
122 - assert_raises(ValueError, lambda: inputs.positive(0))
123 + with pytest.raises(ValueError):
126 def test_positive_negative_input(self):
127 - assert_raises(ValueError, lambda: inputs.positive(-1))
128 + with pytest.raises(ValueError):
129 + inputs.positive(-1)
131 def test_int_range_good(self):
132 int_range = inputs.int_range(1, 5)
133 @@ -231,11 +241,13 @@ class TypesTestCase(unittest.TestCase):
135 def test_int_range_low(self):
136 int_range = inputs.int_range(0, 5)
137 - assert_raises(ValueError, lambda: int_range(-1))
138 + with pytest.raises(ValueError):
141 def test_int_range_high(self):
142 int_range = inputs.int_range(0, 5)
143 - assert_raises(ValueError, lambda: int_range(6))
144 + with pytest.raises(ValueError):
148 def test_isointerval():
149 @@ -389,7 +401,7 @@ def test_isointerval():
152 for value, expected in intervals:
153 - yield assert_equal, inputs.iso8601interval(value), expected
154 + assert inputs.iso8601interval(value) == expected
157 def test_invalid_isointerval_error():
158 @@ -413,12 +425,9 @@ def test_bad_isointervals():
161 for bad_interval in bad_intervals:
165 - inputs.iso8601interval,
168 + with pytest.raises(Exception):
169 + inputs.iso8601interval(bad_interval)
172 if __name__ == '__main__':