Skip to content

Rewrite version tests#220

Merged
avalentino merged 1 commit intoliberfa:mainfrom
eerovaher:version-tests-rewrite
Apr 3, 2026
Merged

Rewrite version tests#220
avalentino merged 1 commit intoliberfa:mainfrom
eerovaher:version-tests-rewrite

Conversation

@eerovaher
Copy link
Copy Markdown
Contributor

No description provided.

return None if b"eraA2af" in out else pytest.skip(reason="system liberfa")


class TestVersion:
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.

The tests in this class do not share any setup or teardown, so the only reason for bundling them together in a class that I can think of is to allow running only version tests with pytest erfa/tests/test_erfa.py::TestVersion. But in practice pytest -k version works just as well and does not require implementing a separate class. If it really is important to separate version tests from others then they should be in a separate module.


class TestVersion:
def test_erfa_version(self):
assert hasattr(erfa.version, 'erfa_version')
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.

These assert hasattr() checks do not serve a useful purpose. If the attribute is missing then trying to access it will cause an AttributeError, but pytest can catch and report those just fine.

def test_erfa_version(self):
assert hasattr(erfa.version, 'erfa_version')
erfa_version = erfa.version.erfa_version
assert isinstance(erfa_version, str)
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.

If types have to be checked in unit tests then the check should be as strict as possible.

@avalentino avalentino merged commit a4d80ab into liberfa:main Apr 3, 2026
28 checks passed
@eerovaher eerovaher deleted the version-tests-rewrite branch April 3, 2026 20:27
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.

2 participants