Skip to content

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

@DanielYang59

Description

@DanielYang59

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions