summaryrefslogtreecommitdiff
path: root/tests/unittests/test_handler/test_schema.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-03-31 16:32:40 -0400
committerGitHub <noreply@github.com>2020-03-31 16:32:40 -0400
commitb698b349c827f30fa60de55e2469a21ae4342669 (patch)
tree91d76d0bc508d39b4de8ee6a06a0e3dcb245cb96 /tests/unittests/test_handler/test_schema.py
parentc478d0bff412c67280dfe8f08568de733f9425a1 (diff)
downloadvyos-cloud-init-b698b349c827f30fa60de55e2469a21ae4342669.tar.gz
vyos-cloud-init-b698b349c827f30fa60de55e2469a21ae4342669.zip
CiTestCase: stop using and remove sys_exit helper (#283)
This shim was required to support Python 2.6, so we no longer need it.
Diffstat (limited to 'tests/unittests/test_handler/test_schema.py')
-rw-r--r--tests/unittests/test_handler/test_schema.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/tests/unittests/test_handler/test_schema.py b/tests/unittests/test_handler/test_schema.py
index 987a89c9..abde02d3 100644
--- a/tests/unittests/test_handler/test_schema.py
+++ b/tests/unittests/test_handler/test_schema.py
@@ -345,12 +345,10 @@ class MainTest(CiTestCase):
def test_main_missing_args(self):
"""Main exits non-zero and reports an error on missing parameters."""
- with mock.patch('sys.exit', side_effect=self.sys_exit):
- with mock.patch('sys.argv', ['mycmd']):
- with mock.patch('sys.stderr', new_callable=StringIO) as \
- m_stderr:
- with self.assertRaises(SystemExit) as context_manager:
- main()
+ with mock.patch('sys.argv', ['mycmd']):
+ with mock.patch('sys.stderr', new_callable=StringIO) as m_stderr:
+ with self.assertRaises(SystemExit) as context_manager:
+ main()
self.assertEqual(1, context_manager.exception.code)
self.assertEqual(
'Expected either --config-file argument or --doc\n',
@@ -359,12 +357,10 @@ class MainTest(CiTestCase):
def test_main_absent_config_file(self):
"""Main exits non-zero when config file is absent."""
myargs = ['mycmd', '--annotate', '--config-file', 'NOT_A_FILE']
- with mock.patch('sys.exit', side_effect=self.sys_exit):
- with mock.patch('sys.argv', myargs):
- with mock.patch('sys.stderr', new_callable=StringIO) as \
- m_stderr:
- with self.assertRaises(SystemExit) as context_manager:
- main()
+ with mock.patch('sys.argv', myargs):
+ with mock.patch('sys.stderr', new_callable=StringIO) as m_stderr:
+ with self.assertRaises(SystemExit) as context_manager:
+ main()
self.assertEqual(1, context_manager.exception.code)
self.assertEqual(
'Configfile NOT_A_FILE does not exist\n',