Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 51 additions & 0 deletions tests/unit/starbase/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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 method that duplicates version trimming in docs/conf.py."""

Comment thread
medubelko marked this conversation as resolved.
def _trim(version):
expression = re.compile(r"\d+\.\d+")
Comment thread
medubelko marked this conversation as resolved.
Outdated

return expression.match(version).group()

Comment thread
medubelko marked this conversation as resolved.
Outdated
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", # NOQA: PT006
Comment thread
medubelko marked this conversation as resolved.
Outdated
Comment thread
medubelko marked this conversation as resolved.
Outdated
[
("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_tagged(version, major_minor, get_major_minor_version):
Comment thread
medubelko marked this conversation as resolved.
Outdated
"""Test the version-to-major-minor function."""
assert get_major_minor_version(version) == major_minor
Loading