From db7a5430d091a0fa15a993b655807bea0bdc3bbe Mon Sep 17 00:00:00 2001 From: ulif <uli@gnufix.de> Date: Thu, 20 Apr 2017 12:37:05 +0200 Subject: [PATCH] Add basic tests for manpage. We will check at least whether the man page is current and ensure that at least words from help output are mentioned in man page. --- tests/test_manpage.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_manpage.py diff --git a/tests/test_manpage.py b/tests/test_manpage.py new file mode 100644 index 0000000..3c18164 --- /dev/null +++ b/tests/test_manpage.py @@ -0,0 +1,33 @@ +import datetime +import os +import pytest + + +@pytest.fixture(scope="function") +def manpage(request): + manpage_path = os.path.join( + os.path.dirname(os.path.dirname(__file__)), 'diceware.1') + with open(manpage_path, 'r') as fd: + content = fd.read() + for token, replacement in [ + ('\\-', '-'), ('\\fB', ''), ('\\fR', '')]: + content = content.replace(token, replacement) + return content + + +class TestManpage(object): + + def test_manpage_contains_current_year(self, manpage): + # the current year appears at least in the manpage + assert str(datetime.datetime.now().year) in manpage + + def test_help_texts_in_manpage(self, manpage): + # the text of help output appear in the manpage + help_text_path = os.path.join( + os.path.dirname(__file__), 'exp_help_output.txt') + with open(help_text_path, 'r') as fd: + help_text = fd.read() + help_text = help_text.replace('<WORDLISTS-DIR>', '') + for word in help_text.split(): + assert word in manpage + -- GitLab