diff options
author | Scott Moser <smoser@ubuntu.com> | 2018-02-12 13:54:50 -0700 |
---|---|---|
committer | Chad Smith <chad.smith@canonical.com> | 2018-02-12 13:54:50 -0700 |
commit | 754f54037aca0f604b8b57ab71b30dad5e5066cf (patch) | |
tree | 0c849988ab451b74088713daa53b7a73190426b1 /tests | |
parent | a1ca220d137cf7b3f79b516980a042ec800a8d91 (diff) | |
download | vyos-cloud-init-754f54037aca0f604b8b57ab71b30dad5e5066cf.tar.gz vyos-cloud-init-754f54037aca0f604b8b57ab71b30dad5e5066cf.zip |
tests: run nosetests in cloudinit/ directory, fix py26 fallout.
When we moved some tests to live under cloudinit/ we inadvertantly
failed to change all things that would run nose to include that
directory.
This changes all the 'nose' invocations to consistently run with
tests/unittests and cloudinit/.
Also, it works around, more correctly this time, a python2.6-ism with
the following code:
with assertRaises(SystemExit) as cm:
sys.exit(2)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_handler/test_schema.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/unittests/test_handler/test_schema.py b/tests/unittests/test_handler/test_schema.py index 648573f6..df67a0e0 100644 --- a/tests/unittests/test_handler/test_schema.py +++ b/tests/unittests/test_handler/test_schema.py @@ -336,11 +336,13 @@ class MainTest(CiTestCase): def test_main_missing_args(self): """Main exits non-zero and reports an error on missing parameters.""" - 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', str(context_manager.exception)) + 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() + self.assertEqual(1, context_manager.exception.code) self.assertEqual( 'Expected either --config-file argument or --doc\n', m_stderr.getvalue()) |