Skip to content

test: add version test module#560

Open
medubelko wants to merge 4 commits into
mainfrom
work/add-version-tests
Open

test: add version test module#560
medubelko wants to merge 4 commits into
mainfrom
work/add-version-tests

Conversation

@medubelko

Copy link
Copy Markdown
Contributor

The version attribute inside a craft (craft.__version__) is generated by Setuptools, so it's outside of the scope of the modules. The docs, however, rely on it for the version in the toolbar.

This PR adds a standalone test module for the version string, and checks against common values. It mocks a function that I plan to add to conf.py, but isn't implemented yet.

This is a first step toward fixing #532.

Concerns

There's nothing to guarantee conf.py will have this function. We're creating a value in the docs, then mocking the logic in an unrelated test, so there's no coupling.

I think it would be more ideal if each craft could provide something like craft.__version_major_minor__, so the logic would reside in the app itself, not the docs. Is there a simple place to put that?


  • I've followed the contribution guidelines.
  • I've signed the CLA.
  • I've successfully run make lint && make test.
  • I've added or updated any relevant documentation.
  • In documents I changed, I added a meta description if one was missing.
  • I've updated the relevant release notes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated unit-test module around the project’s __version__ attribute and a “major.minor” extraction helper intended to mirror (future) docs toolbar version formatting, as a step toward addressing issue #532.

Changes:

  • Added tests/unit/starbase/test_version.py with checks for starcraft.__version__ and a helper that extracts MAJOR.MINOR from version strings.
  • Removed the test_version assertion from tests/unit/starbase/test_init.py (moved into the new module).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
tests/unit/starbase/test_version.py New unit tests for __version__ and major/minor parsing logic.
tests/unit/starbase/test_init.py Removes version assertion now covered by the new test module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/starbase/test_version.py
Comment thread tests/unit/starbase/test_version.py
Comment thread tests/unit/starbase/test_version.py Outdated
Comment thread tests/unit/starbase/test_version.py Outdated
Comment thread tests/unit/starbase/test_version.py
Comment thread tests/unit/starbase/test_version.py Outdated
Comment thread tests/unit/starbase/test_version.py
Comment thread tests/unit/starbase/test_version.py Outdated
"""Fixture method that duplicates version trimming in docs/conf.py."""

def _trim(version):
expression = re.compile(r"\d+\.\d+")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is calling re excessive here? I use it as a crutch, but I feel like it might be overkill.

Comment thread tests/unit/starbase/test_version.py Outdated

@lengau lengau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ACCIDENTAL CLANKER REPLY REDACTED]

@medubelko

Copy link
Copy Markdown
Contributor Author

On second look, this might belong in the existing version integration test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants