Skip to content

Commit

Permalink
Add tests for version number matching
Browse files Browse the repository at this point in the history
  • Loading branch information
nathom committed Jan 11, 2024
1 parent 63f3901 commit 577d914
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions streamrip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .config import Config

__all__ = ["Config", "media", "metadata", "converter", "db", "exceptions"]
__version__ = "2.0.2"
Binary file modified tests/silence.flac
Binary file not shown.
42 changes: 42 additions & 0 deletions tests/test_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import re

import pytest

from streamrip import __version__ as init_version
from streamrip.config import CURRENT_CONFIG_VERSION

toml_version_re = re.compile(r'version\s*\=\s*"([\d\.]+)"')


@pytest.fixture
def pyproject_version() -> str:
with open("pyproject.toml") as f:
m = toml_version_re.search(f.read())
assert m is not None
return m.group(1)


@pytest.fixture
def config_version() -> str | None:
with open("streamrip/config.toml") as f:
m = toml_version_re.search(f.read())
assert m is not None
return m.group(1)


@pytest.fixture
def click_version() -> str | None:
r = re.compile(r'\@click\.version_option\(version="([\d\.]+)"\)')
with open("streamrip/rip/cli.py") as f:
m = r.search(f.read())
assert m is not None
return m.group(1)


def test_config_versions_match(config_version):
assert config_version == CURRENT_CONFIG_VERSION


def test_streamrip_versions_match(pyproject_version, click_version):
assert pyproject_version == click_version
assert click_version == init_version

0 comments on commit 577d914

Please sign in to comment.