Skip to content

Commit

Permalink
test: Fix version test not working under tox
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueDrink9 committed Aug 16, 2021
1 parent 45817c1 commit 596e402
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import subprocess
import pathlib

import pytest
from hamcrest import *

import autokey.common

autokey_repo_path = pathlib.Path(__file__).parent

def get_recent_git_tag(extra_args=[]):
command =["git", "-C", str(autokey_repo_path), "describe", "--abbrev=0",
"--tags", *extra_args]
tag = subprocess.run(command, stdout=subprocess.PIPE).stdout.decode().rstrip()
return tag
# Ensure that the version number is up to date in common.py
# Skip this test if the tag contains "CI_test"
@pytest.mark.skipif("CI_test" in subprocess.run(["git", "describe",
"--abbrev=0", "--tags"], stdout=subprocess.PIPE).stdout.decode().rstrip(),
@pytest.mark.skipif("CI_test" in get_recent_git_tag(),
reason="Don't test version for CI_test tags")
def test_version_number_accurate():
git_tag_version = subprocess.run(["git", "describe", "--abbrev=0",
"--tags", '--match="v*.*.*"'],
stdout=subprocess.PIPE).stdout.decode().rstrip()
# git_tag_version = get_recent_git_tag(["--match='v*.*.*'"])
git_tag_version = get_recent_git_tag()
assert_that(git_tag_version, is_(equal_to("v"+autokey.common.VERSION)),
"Ensure the most recent git tag version matches the version number in lib/autokey/common.py")

0 comments on commit 596e402

Please sign in to comment.