Skip to content

Commit 525708e

Browse files
authored
Merge pull request #29265 from Rostepher/remove-assert-not-raises
[NFC][Build System: build-script] Remove TestCase.assertNotRaises method.
2 parents dadd43c + f5c56f2 commit 525708e

File tree

5 files changed

+235
-302
lines changed

5 files changed

+235
-302
lines changed

utils/build_swift/tests/argparse/test_actions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ def test_multiple_destinations(self):
4141
self.assertEqual(action.dests, ['foo', 'bar'])
4242

4343
def test_supports_dest_argument(self):
44-
with self.assertNotRaises(Exception):
45-
action = actions.Action([], [], dest='foo')
44+
action = actions.Action([], [], dest='foo')
4645

47-
self.assertEqual(action.dest, SUPPRESS)
46+
self.assertEqual(action.dest, SUPPRESS)
4847

4948
def test_call_not_implemented(self):
5049
action = actions.Action([], [])

utils/build_swift/tests/argparse/test_types.py

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,25 @@ def test_init_list(self):
2626
version = types.CompilerVersion([1, 0, 0])
2727
self.assertEqual(version.components, (1, 0, 0))
2828

29-
with self.assertNotRaises(ValueError):
30-
types.CompilerVersion([1, 0])
31-
types.CompilerVersion([2, 3, 4])
32-
types.CompilerVersion([3, 1, 4, 1, 5, 9])
29+
types.CompilerVersion([1, 0])
30+
types.CompilerVersion([2, 3, 4])
31+
types.CompilerVersion([3, 1, 4, 1, 5, 9])
3332

3433
def test_init_tuple(self):
3534
version = types.CompilerVersion((1, 0, 0))
3635
self.assertEqual(version.components, (1, 0, 0))
3736

38-
with self.assertNotRaises(ValueError):
39-
types.CompilerVersion((1, 0))
40-
types.CompilerVersion((2, 3, 4))
41-
types.CompilerVersion((3, 1, 4, 1, 5, 9))
37+
types.CompilerVersion((1, 0))
38+
types.CompilerVersion((2, 3, 4))
39+
types.CompilerVersion((3, 1, 4, 1, 5, 9))
4240

4341
def test_init_str(self):
4442
version = types.CompilerVersion('1.0.0')
4543
self.assertEqual(version.components, (1, 0, 0))
4644

47-
with self.assertNotRaises(ValueError):
48-
types.CompilerVersion('1.0')
49-
types.CompilerVersion('2.3.4')
50-
types.CompilerVersion('3.1.4.1.5.9')
45+
types.CompilerVersion('1.0')
46+
types.CompilerVersion('2.3.4')
47+
types.CompilerVersion('3.1.4.1.5.9')
5148

5249
def test_init_invalid_value(self):
5350
with self.assertRaises(ValueError):
@@ -153,9 +150,7 @@ def test_expands_path(self):
153150

154151
def test_assert_exists(self):
155152
path_type = types.PathType(assert_exists=True)
156-
157-
with self.assertNotRaises(ArgumentTypeError):
158-
path_type(__file__)
153+
path_type(__file__)
159154

160155
with self.assertRaises(ArgumentTypeError):
161156
path_type('/nonsensisal/path/')
@@ -171,8 +166,7 @@ def test_assert_executable(self):
171166

172167
bash_path = '/bin/bash'
173168
if os.path.isfile(bash_path) and os.access(bash_path, os.X_OK):
174-
with self.assertNotRaises(ArgumentTypeError):
175-
path_type(bash_path)
169+
path_type(bash_path)
176170

177171
with self.assertRaises(ArgumentTypeError):
178172
path_type(__file__)
@@ -189,10 +183,9 @@ class TestRegexType(TestCase):
189183
def test_regex_match(self):
190184
regex_type = types.RegexType(r'a+b*')
191185

192-
with self.assertNotRaises(ArgumentTypeError):
193-
regex_type('a')
194-
regex_type('aab')
195-
regex_type('abbbbbbb')
186+
regex_type('a')
187+
regex_type('aab')
188+
regex_type('abbbbbbb')
196189

197190
def test_raises_argument_error(self):
198191
regex_type = types.RegexType(r'a+b*')
@@ -216,11 +209,10 @@ def test_valid_clang_version(self):
216209
self.assertIsInstance(version, types.CompilerVersion)
217210
self.assertEqual(version.components, (1, 0, 0, 1))
218211

219-
with self.assertNotRaises(ArgumentTypeError):
220-
clang_version_type('1.0.0')
221-
clang_version_type('3.0.2.1')
222-
clang_version_type('200.0.56.3')
223-
clang_version_type('100000.0.0.1')
212+
clang_version_type('1.0.0')
213+
clang_version_type('3.0.2.1')
214+
clang_version_type('200.0.56.3')
215+
clang_version_type('100000.0.0.1')
224216

225217
def test_invalid_clang_version(self):
226218
clang_version_type = types.ClangVersionType()
@@ -245,11 +237,10 @@ def test_valid_swift_version(self):
245237
self.assertIsInstance(version, types.CompilerVersion)
246238
self.assertEqual(version.components, (1, 0, 1))
247239

248-
with self.assertNotRaises(ArgumentTypeError):
249-
swift_version_type('1.0')
250-
swift_version_type('3.0.2')
251-
swift_version_type('200.0.56')
252-
swift_version_type('100000.0.1')
240+
swift_version_type('1.0')
241+
swift_version_type('3.0.2')
242+
swift_version_type('200.0.56')
243+
swift_version_type('100000.0.1')
253244

254245
def test_invalid_swift_version(self):
255246
swift_version_type = types.SwiftVersionType()

0 commit comments

Comments
 (0)