1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2024-10-27 20:34:27 +00:00
TheLocehiliosan_yadm/test/test_version.py
Tim Byrne e7f9616b39
Rewrite testing system (#119)
The new test system is written with py.test. These tests are more
comprehensive, run faster by an order of magnitude, and are far more
maintainable. The tests themselves conform to PEP8.
2019-02-20 07:48:25 -06:00

36 lines
934 B
Python

"""Test version"""
import re
import pytest
@pytest.fixture(scope='module')
def expected_version(yadm):
"""
Expected semantic version number. This is taken directly out of yadm,
searching for the VERSION= string.
"""
yadm_version = re.findall(
r'VERSION=([^\n]+)',
open(yadm).read())
if yadm_version:
return yadm_version[0]
pytest.fail(f'version not found in {yadm}')
return 'not found'
def test_semantic_version(expected_version):
"""Version is semantic"""
# semantic version conforms to MAJOR.MINOR.PATCH
assert re.search(r'^\d+\.\d+\.\d+$', expected_version), (
'does not conform to MAJOR.MINOR.PATCH')
def test_reported_version(
runner, yadm_y, expected_version):
"""Report correct version"""
run = runner(command=yadm_y('version'))
assert run.success
assert run.err == ''
assert run.out == f'yadm {expected_version}\n'