From 1124b6f86c5ea995dc1c13db80cb1a78282d3418 Mon Sep 17 00:00:00 2001 From: Chris Berkhout Date: Thu, 29 Jul 2021 17:15:36 +0200 Subject: [PATCH] Test formatting of list of sources. --- tests/pricehist/test_sources.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/pricehist/test_sources.py diff --git a/tests/pricehist/test_sources.py b/tests/pricehist/test_sources.py new file mode 100644 index 0000000..977cb79 --- /dev/null +++ b/tests/pricehist/test_sources.py @@ -0,0 +1,16 @@ +import re + +from pricehist import sources + + +def test_formatted_includes_ecb(): + lines = sources.formatted().splitlines() + assert any(re.match(r"ecb +European Central Bank", line) for line in lines) + + +def test_formatted_names_aligned(): + lines = sources.formatted().splitlines() + offsets = [len(re.match(r"(\w+ +)[^ ]", line)[1]) for line in lines] + first = offsets[0] + assert first > 1 + assert all(offset == first for offset in offsets)