Skip to content

[NFC][Build System: build-script] Remove TestCase.assertNotRaises method. #29265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions utils/build_swift/tests/argparse/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ def test_multiple_destinations(self):
self.assertEqual(action.dests, ['foo', 'bar'])

def test_supports_dest_argument(self):
with self.assertNotRaises(Exception):
action = actions.Action([], [], dest='foo')
action = actions.Action([], [], dest='foo')

self.assertEqual(action.dest, SUPPRESS)
self.assertEqual(action.dest, SUPPRESS)

def test_call_not_implemented(self):
action = actions.Action([], [])
Expand Down
53 changes: 22 additions & 31 deletions utils/build_swift/tests/argparse/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,25 @@ def test_init_list(self):
version = types.CompilerVersion([1, 0, 0])
self.assertEqual(version.components, (1, 0, 0))

with self.assertNotRaises(ValueError):
types.CompilerVersion([1, 0])
types.CompilerVersion([2, 3, 4])
types.CompilerVersion([3, 1, 4, 1, 5, 9])
types.CompilerVersion([1, 0])
types.CompilerVersion([2, 3, 4])
types.CompilerVersion([3, 1, 4, 1, 5, 9])

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

with self.assertNotRaises(ValueError):
types.CompilerVersion((1, 0))
types.CompilerVersion((2, 3, 4))
types.CompilerVersion((3, 1, 4, 1, 5, 9))
types.CompilerVersion((1, 0))
types.CompilerVersion((2, 3, 4))
types.CompilerVersion((3, 1, 4, 1, 5, 9))

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

with self.assertNotRaises(ValueError):
types.CompilerVersion('1.0')
types.CompilerVersion('2.3.4')
types.CompilerVersion('3.1.4.1.5.9')
types.CompilerVersion('1.0')
types.CompilerVersion('2.3.4')
types.CompilerVersion('3.1.4.1.5.9')

def test_init_invalid_value(self):
with self.assertRaises(ValueError):
Expand Down Expand Up @@ -153,9 +150,7 @@ def test_expands_path(self):

def test_assert_exists(self):
path_type = types.PathType(assert_exists=True)

with self.assertNotRaises(ArgumentTypeError):
path_type(__file__)
path_type(__file__)

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

bash_path = '/bin/bash'
if os.path.isfile(bash_path) and os.access(bash_path, os.X_OK):
with self.assertNotRaises(ArgumentTypeError):
path_type(bash_path)
path_type(bash_path)

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

with self.assertNotRaises(ArgumentTypeError):
regex_type('a')
regex_type('aab')
regex_type('abbbbbbb')
regex_type('a')
regex_type('aab')
regex_type('abbbbbbb')

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

with self.assertNotRaises(ArgumentTypeError):
clang_version_type('1.0.0')
clang_version_type('3.0.2.1')
clang_version_type('200.0.56.3')
clang_version_type('100000.0.0.1')
clang_version_type('1.0.0')
clang_version_type('3.0.2.1')
clang_version_type('200.0.56.3')
clang_version_type('100000.0.0.1')

def test_invalid_clang_version(self):
clang_version_type = types.ClangVersionType()
Expand All @@ -245,11 +237,10 @@ def test_valid_swift_version(self):
self.assertIsInstance(version, types.CompilerVersion)
self.assertEqual(version.components, (1, 0, 1))

with self.assertNotRaises(ArgumentTypeError):
swift_version_type('1.0')
swift_version_type('3.0.2')
swift_version_type('200.0.56')
swift_version_type('100000.0.1')
swift_version_type('1.0')
swift_version_type('3.0.2')
swift_version_type('200.0.56')
swift_version_type('100000.0.1')

def test_invalid_swift_version(self):
swift_version_type = types.SwiftVersionType()
Expand Down
Loading