Skip to content

Convert tests to pytest - #28

Merged
TomTheBear merged 4 commits into
RRZE-HPC:masterfrom
max-models:convert-tests-to-pytest
Jun 1, 2026
Merged

TomTheBear merged 4 commits into
RRZE-HPC:masterfrom
max-models:convert-tests-to-pytest

Conversation

@max-models

Copy link
Copy Markdown
Contributor

No description provided.

@TomTheBear

Copy link
Copy Markdown
Member

Thanks for your modernization efforts.

Just as a side question: Why pytest and not unittest? I have another Python project MachineState where we add tests at the moment and use unittest there because it is part of the standard library. We are still early in progress, so if there are good reasons for pytest, we could still switch.

@max-models

Copy link
Copy Markdown
Contributor Author

From what I know, there is no built-in equivalent to pytest.mark.parametrize in the native unittest module. That means that you can really nicely run the same test with many different parameters, like this for example:

import pytest

@pytest.mark.parametrize("x, y, expected", [
    (1, 2, 3),
    (10, 5, 15),
    (-1, 1, 0),
])
def test_add(x, y, expected):
    assert x + y == expected

I think you can achieve something similar with subTest in unittest but it didn't seem as clean to me

For me, that is the best reason to use pytest! :) I'm sure there are a few more reasons, but in almost every python project I worked on I used pytest, so it's the tool I know best, that's why I suggested it 😅

@TomTheBear
TomTheBear merged commit 27d81d8 into RRZE-HPC:master Jun 1, 2026
5 checks passed
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