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 = """ exclude = """
zulip/integrations/perforce/git_p4.py zulip/integrations/perforce/git_p4.py
zulip/tests/test_default_arguments.py
zulip_bots/zulip_bots/bots zulip_bots/zulip_bots/bots
zulip_bots/generate_manifest.py zulip_bots/generate_manifest.py

View file

@ -16,8 +16,10 @@ else:
class TestDefaultArguments(TestCase): class TestDefaultArguments(TestCase):
def test_invalid_arguments(self): def test_invalid_arguments(self):
# type: () -> None
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum")) 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: 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']) parser.parse_args(['invalid argument'])
self.assertEqual(cm.exception.code, 2) self.assertEqual(cm.exception.code, 2)
# Assert that invalid arguments exit with printing the full usage (non-standard behavior) # Assert that invalid arguments exit with printing the full usage (non-standard behavior)
@ -32,6 +34,7 @@ Zulip API configuration:
@patch('os.path.exists', return_value=False) @patch('os.path.exists', return_value=False)
def test_config_path_with_tilde(self, mock_os_path_exists): def test_config_path_with_tilde(self, mock_os_path_exists):
# type: (bool) -> None
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum")) parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
test_path = '~/zuliprc' test_path = '~/zuliprc'
args = parser.parse_args(['--config-file', test_path]) args = parser.parse_args(['--config-file', test_path])