Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/unit/starbase/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
from pytest_mock import MockerFixture


def test_version():
assert starcraft.__version__ is not None


def test_hello(mocker: MockerFixture):
mock_print = mocker.patch("builtins.print")

Expand Down
52 changes: 52 additions & 0 deletions tests/unit/starbase/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is part of starcraft.
#
# Copyright 2026 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
# SATISFACTORY QUALITY, 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/>.
"""Basic tests for Starbase version attributes."""
Comment thread
medubelko marked this conversation as resolved.

import re

import pytest
import starcraft


@pytest.fixture
def get_major_minor_version():
"""Fixture function that duplicates version trimming in docs/conf.py."""

def _trim(version: str) -> str:
match = re.match(r"\d+\.\d+", version)
assert match is not None

return match.group()

return _trim


def test_version():
"""Test that the version attribute is generating."""
Comment thread
medubelko marked this conversation as resolved.
assert starcraft.__version__ is not None


@pytest.mark.parametrize(
("version", "major_minor"),
[
("9.0.0", "9.0"), # Tagged
("9.0.0-23-gc2a9d6349", "9.0"), # Tagged + new commits
Comment thread
medubelko marked this conversation as resolved.
("0.0.post836+g494e37055.d20260612", "0.0"), # Untagged
],
)
def test_version_major_minor(version, major_minor, get_major_minor_version):
"""Test the version-to-major-minor function."""
assert get_major_minor_version(version) == major_minor