for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
# Copyright Pincer 2021-Present
# Full MIT License can be found in `LICENSE` at the project root.
from pincer.objects import UserMessage
class Message:
def __init__(self, content):
self.content = content
clean_content = UserMessage.clean_content
class TestUserMessages:
def test_clean_content(self):
If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example
class Foo: def some_method(self, x, y): return x + y;
could be written as
class Foo: @classmethod def some_method(cls, x, y): return x + y;
assert Message('Hello, world!').clean_content == 'Hello, world!'
assert Message('_*`Hello, world!`*_').clean_content == 'Hello, world!'
assert Message('__~~Hello, world!~~__').clean_content == 'Hello, world!'
assert Message('||Hello, world!||').clean_content == 'Hello, world!'
assert Message('```py\nfoo\nbar\n```').clean_content == 'foo\nbar'