Skip to content

[build-script] Fix tests that assertRaises incorrectly #36809

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
Apr 8, 2021
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
11 changes: 9 additions & 2 deletions utils/build_swift/tests/build_swift/argparse/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def test_raises_argument_error(self):

with self.assertRaises(ArgumentTypeError):
regex_type('')
with self.assertRaises(ArgumentTypeError):
regex_type('b')
with self.assertRaises(ArgumentTypeError):
regex_type('baaaa')


Expand All @@ -165,9 +167,12 @@ def test_invalid_clang_version(self):

with self.assertRaises(ArgumentTypeError):
clang_version_type('2')
with self.assertRaises(ArgumentTypeError):
clang_version_type('3.0')
clang_version_type('1.8.0.2')
clang_version_type('100.0.56.1')
with self.assertRaises(ArgumentTypeError):
clang_version_type('1.8.0.2.1')
with self.assertRaises(ArgumentTypeError):
clang_version_type('100.0.56.1.1')


class TestSwiftVersionType(unittest.TestCase):
Expand Down Expand Up @@ -201,7 +206,9 @@ def test_invalid_swift_version(self):

with self.assertRaises(ArgumentTypeError):
swift_version_type('2')
with self.assertRaises(ArgumentTypeError):
swift_version_type('1.8.0.2.3.1')
with self.assertRaises(ArgumentTypeError):
swift_version_type('100.0.56.1.85.1')


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test(self):
with utils.redirect_stdout() as output:
with self.assertRaises(ParserError):
self.parse_args([option.option_string])
self.assertNotEmpty(output)
self.assertTrue(output)

return test

Expand Down Expand Up @@ -454,7 +454,9 @@ def test_option_clang_compiler_version(self):

with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1.2'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '0.0.0.0.1'])

def test_option_clang_user_visible_version(self):
Expand All @@ -466,7 +468,9 @@ def test_option_clang_user_visible_version(self):

with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1.2'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '0.0.0.0.1'])

def test_option_swift_compiler_version(self):
Expand All @@ -478,6 +482,7 @@ def test_option_swift_compiler_version(self):

with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '0.0.0.1'])

def test_option_swift_user_visible_version(self):
Expand All @@ -489,6 +494,7 @@ def test_option_swift_user_visible_version(self):

with self.assertRaises(ParserError):
self.parse_default_args([option_string, '1'])
with self.assertRaises(ParserError):
self.parse_default_args([option_string, '0.0.0.1'])

def test_option_I(self):
Expand Down