black: Reformat without skipping string normalization.

This commit is contained in:
PIG208 2021-05-28 17:05:11 +08:00 committed by Tim Abbott
parent fba21bb00d
commit 6f3f9bf7e4
178 changed files with 5242 additions and 5242 deletions

View file

@ -15,8 +15,8 @@ class TestDefaultArguments(TestCase):
def test_invalid_arguments(self) -> None:
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
with self.assertRaises(SystemExit) as cm:
with patch('sys.stderr', new=io.StringIO()) as mock_stderr:
parser.parse_args(['invalid argument'])
with patch("sys.stderr", new=io.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(
@ -32,20 +32,20 @@ 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: bool) -> None:
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage="lorem ipsum"))
test_path = '~/zuliprc'
args = parser.parse_args(['--config-file', test_path])
test_path = "~/zuliprc"
args = parser.parse_args(["--config-file", test_path])
with self.assertRaises(ZulipError) as cm:
zulip.init_from_options(args)
expanded_test_path = os.path.abspath(os.path.expanduser(test_path))
self.assertEqual(
str(cm.exception),
'api_key or email not specified and '
'file {} does not exist'.format(expanded_test_path),
"api_key or email not specified and "
"file {} does not exist".format(expanded_test_path),
)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

View file

@ -9,17 +9,17 @@ import zulip
class TestHashUtilDecode(TestCase):
def test_hash_util_decode(self) -> None:
tests = [
('topic', 'topic'),
('.2Edot', '.dot'),
('.23stream.20name', '#stream name'),
('(no.20topic)', '(no topic)'),
('.3Cstrong.3Ebold.3C.2Fstrong.3E', '<strong>bold</strong>'),
('.3Asome_emoji.3A', ':some_emoji:'),
("topic", "topic"),
(".2Edot", ".dot"),
(".23stream.20name", "#stream name"),
("(no.20topic)", "(no topic)"),
(".3Cstrong.3Ebold.3C.2Fstrong.3E", "<strong>bold</strong>"),
(".3Asome_emoji.3A", ":some_emoji:"),
]
for encoded_string, decoded_string in tests:
with self.subTest(encoded_string=encoded_string):
self.assertEqual(zulip.hash_util_decode(encoded_string), decoded_string)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()