[Tests] makes sure --version works

Directly reads the version number from pyproject.toml
This commit is contained in:
MinchinWeb 2020-03-21 21:50:39 -06:00
parent e489971877
commit 9017f96576
4 changed files with 36 additions and 1 deletions

View file

@ -19,6 +19,8 @@ import keyring
import tzlocal
import shlex
import sys
from pathlib import Path
import tomlkit
consts = pdt.Constants(usePyICU=False)
consts.DOWParseStyle = -1 # Prefers past weekdays
@ -207,6 +209,15 @@ def check_output_time_inline(context, text):
assert output_date in out, output_date
@then('the output should contain pyproject.toml version')
def check_output_version_inline(context):
out = context.stdout_capture.getvalue()
pyproject = (Path(__file__) / '..' / '..' / '..' / 'pyproject.toml').resolve()
pyproject_contents = tomlkit.parse(pyproject.open().read())
pyproject_version = pyproject_contents['tool']['poetry']['version']
assert pyproject_version in out, pyproject_version
@then("the output should contain")
@then('the output should contain "{text}"')
@then('the output should contain "{text}" or "{text2}"')