diff --git a/src/octoprint/logging/__init__.py b/src/octoprint/logging/__init__.py index a762718c4..6a0043ba5 100644 --- a/src/octoprint/logging/__init__.py +++ b/src/octoprint/logging/__init__.py @@ -79,17 +79,18 @@ def get_divider_line(c, message=None, length=78, indent=3): Examples: - >>> get_divider_line("-") + >>> from octoprint.util import to_native_str + >>> to_native_str(get_divider_line("-")) '------------------------------------------------------------------------------' - >>> get_divider_line("=", length=10) + >>> to_native_str(get_divider_line("=", length=10)) '==========' - >>> get_divider_line("-", message="Hi", length=10) + >>> to_native_str(get_divider_line("-", message="Hi", length=10)) '--- Hi ---' - >>> get_divider_line("-", message="A slightly longer text") + >>> to_native_str(get_divider_line("-", message="A slightly longer text")) '--- A slightly longer text ---------------------------------------------------' - >>> get_divider_line("-", message="A slightly longer text", indent=5) + >>> to_native_str(get_divider_line("-", message="A slightly longer text", indent=5)) '----- A slightly longer text -------------------------------------------------' - >>> get_divider_line("-", message="Hello World!", length=10) + >>> to_native_str(get_divider_line("-", message="Hello World!", length=10)) '--- Hello World!' >>> get_divider_line(None) Traceback (most recent call last): diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index 67139eaf8..864c8732b 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -434,11 +434,12 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin, _image_tag_re = re.compile(r'') def _strip_images(text): """ - >>> _strip_images("I'm a link and this is an image: foo") + >>> from octoprint.util import to_native_str + >>> to_native_str(_strip_images("I'm a link and this is an image: foo")) "I'm a link and this is an image: " - >>> _strip_images("One and two and three and four \\"four\\"") + >>> to_native_str(_strip_images("One and two and three and four \\"four\\"")) 'One and two and three and four ' - >>> _strip_images("No images here") + >>> to_native_str(_strip_images("No images here")) 'No images here' """ return _image_tag_re.sub('', text) @@ -446,9 +447,10 @@ def _strip_images(text): def _replace_images(text, callback): """ >>> callback = lambda img: "foobar" - >>> _replace_images("I'm a link and this is an image: foo", callback) + >>> from octoprint.util import to_native_str + >>> to_native_str(_replace_images("I'm a link and this is an image: foo", callback)) "I'm a link and this is an image: foobar" - >>> _replace_images("One and two and three and four \\"four\\"", callback) + >>> to_native_str(_replace_images("One and two and three and four \\"four\\"", callback)) 'One foobar and two foobar and three foobar and four foobar' """ result = text @@ -461,13 +463,14 @@ def _replace_images(text, callback): _image_src_re = re.compile(r'src=(?P[\'"]*)(?P.*?)(?P=quote)(?=\s+|>)') def _lazy_images(text, placeholder=None): """ - >>> _lazy_images("I'm a link and this is an image: foo") + >>> from octoprint.util import to_native_str + >>> to_native_str(_lazy_images("I'm a link and this is an image: foo")) 'I\\'m a link and this is an image: \\'foo\\'' - >>> _lazy_images("I'm a link and this is an image: foo", placeholder="ph.png") + >>> to_native_str(_lazy_images("I'm a link and this is an image: foo", placeholder="ph.png")) 'I\\'m a link and this is an image: \\'foo\\'' - >>> _lazy_images("One and two and three and four \\"four\\"", placeholder="ph.png") + >>> to_native_str(_lazy_images("One and two and three and four \\"four\\"", placeholder="ph.png")) 'One and two and three and four four' - >>> _lazy_images("No images here") + >>> to_native_str(_lazy_images("No images here")) 'No images here' """ if placeholder is None: @@ -487,9 +490,10 @@ def _lazy_images(text, placeholder=None): def _strip_tags(text): """ - >>> _strip_tags("Hello world<img src='foo.jpg'>") + >>> from octoprint.util import to_native_str + >>> to_native_str(_strip_tags("Hello world<img src='foo.jpg'>")) "Hello world<img src='foo.jpg'>" - >>> _strip_tags("> > Foo") + >>> to_native_str(_strip_tags("> > Foo")) '> > Foo' """ try: