From 643d4cacd3c05abbfde9cb4bae98f2d6a50405a8 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 29 Jan 2019 20:05:16 +0000 Subject: [PATCH] bugdown tests: Pass message stub to bugdown_convert(). This makes the calling sequence slightly more realistic (without any additional overhead). --- zerver/tests/test_bugdown.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index bc533723bd..34d7b38b68 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -51,7 +51,10 @@ import os import ujson import urllib -from typing import Any, AnyStr, Dict, List, Optional, Set, Tuple +from typing import cast, Any, AnyStr, Dict, List, Optional, Set, Tuple + +class FakeMessage: + pass class FencedBlockPreprocessorTest(TestCase): def test_simple_quoting(self) -> None: @@ -166,8 +169,15 @@ class FencedBlockPreprocessorTest(TestCase): lines = processor.run(markdown) self.assertEqual(lines, expected) -def bugdown_convert(text: str) -> str: - return bugdown.convert(text, message_realm=get_realm('zulip')) +def bugdown_convert(content: str) -> str: + message = cast(Message, FakeMessage()) + message.content = content + message.id = 999 + return bugdown.convert( + content=content, + message_realm=get_realm('zulip'), + message=message, + ) class BugdownMiscTest(ZulipTestCase): def test_diffs_work_as_expected(self) -> None: