Add sentinel value for parse_mode which can be None itself

Resolves #302. We decided to use sentinel pattern (https://python-patterns.guide/python/sentinel-object/) as a solution, but got a few problems with plain `object()`, so instead we use unittest.mock.sentinel and we hope it won't cause side effects.

Most of work done via tg-codegen (https://github.com/aiogram/tg-codegen/pull/1), so it's good to review only implementation of sentinel, processing sentinel in `prepare_parse_mode`, changes in base method model and little test fixes.
This commit is contained in:
Dima Boger 2020-04-12 17:16:35 +03:00
parent 9f00a02e4d
commit 023245c76b
34 changed files with 108 additions and 53 deletions

View file

@ -59,4 +59,4 @@ class TestPrepareParseMode:
def test_bot_not_in_context(self):
data = {}
prepare_parse_mode(data)
assert "parse_mode" not in data
assert data["parse_mode"] is None