Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dev/Test] Migrate PymatgenTest from unittest.TestCase to pytest #4202

Open
DanielYang59 opened this issue Nov 28, 2024 · 0 comments · May be fixed by #4212
Open

[Dev/Test] Migrate PymatgenTest from unittest.TestCase to pytest #4202

DanielYang59 opened this issue Nov 28, 2024 · 0 comments · May be fixed by #4212

Comments

@DanielYang59
Copy link
Contributor

DanielYang59 commented Nov 28, 2024

Current pytest framework isn't fully compatible with unittest.TestCase, we should consider migrate to pytest framework:

The following pytest features do not work, and probably never will due to different design philosophies:

Fixtures (except for autouse fixtures, see below);
Parametrization;
Custom hooks;


For example pytest.mark.parametrize doesn't work:

from unittest import TestCase

import pytest


class TestPytest(TestCase):
    @pytest.mark.parametrize("foo", ["hello", "world"])
    def test_demo(self, foo):
        assert isinstance(foo, str)

Gives:

    def _callTestMethod(self, method):
>       if method() is not None:
E       TypeError: TestPytest.test_demo() missing 1 required positional argument: 'foo'

While the following works just fine:

- class TestPytest(TestCase):
+ class TestPytest:
@DanielYang59 DanielYang59 changed the title [Dev/Test] Migrate PymatgenTest from TestCase to pytest [Dev/Test] Migrate PymatgenTest from unittest.TestCase to pytest Nov 29, 2024
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 a pull request may close this issue.

1 participant