mypy: zulip: Fix errors in tests/test_default_arguments.py.

This commit is contained in:
Alena Volkova 2017-10-11 20:54:09 -04:00
parent 99785a1be4
commit fe6deb2e03
2 changed files with 5 additions and 3 deletions

View file

@ -20,7 +20,6 @@ sys.path.append(os.path.dirname(TOOLS_DIR))
exclude = """
zulip/integrations/perforce/git_p4.py
zulip/tests/test_default_arguments.py
zulip_bots/zulip_bots/bots
zulip_bots/generate_manifest.py

View file

@ -16,9 +16,11 @@ else:
class TestDefaultArguments(TestCase):
def test_invalid_arguments(self):
# type: () -> None
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
with self.assertRaises(SystemExit) as cm, patch('sys.stderr', new=six.StringIO()) as mock_stderr:
parser.parse_args(['invalid argument'])
with self.assertRaises(SystemExit) as cm: # type: ignore # error: "assertRaises" doesn't match argument types
with patch('sys.stderr', new=six.StringIO()) as mock_stderr:
parser.parse_args(['invalid argument'])
self.assertEqual(cm.exception.code, 2)
# Assert that invalid arguments exit with printing the full usage (non-standard behavior)
self.assertTrue(mock_stderr.getvalue().startswith("""usage: lorem ipsum
@ -32,6 +34,7 @@ Zulip API configuration:
@patch('os.path.exists', return_value=False)
def test_config_path_with_tilde(self, mock_os_path_exists):
# type: (bool) -> None
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
test_path = '~/zuliprc'
args = parser.parse_args(['--config-file', test_path])