File: test_common.py

package info (click to toggle)
autokey 0.96.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,468 kB
  • sloc: python: 11,473; xml: 3,260; javascript: 249; sh: 24; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,717 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (C) 2020 BlueDrink9

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# 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
# Skip git version test during debian build
@pytest.mark.skip(reason="Don't test git version in debian build")
# 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 get_recent_git_tag(),
    reason="Don't test version for CI_test tags")
def test_version_number_accurate():
    # 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")