Testing

gpaw/test/, pytest.ini

Run the test-suite (no MPI):

$ pip install pytest
$ cd /tmp/gpaw
$ pytest
.................^C^C^C^C^C^C^C^C^C
$ pip install pytest-xdist
$ pytest -n4 -q
s.................s..............................................s.. [ 11%]
....................x..........................................s.... [ 22%]
...
...........sss.....sss...............s.................s.........s.. [100%]
642 passed, 34 skipped, 9 xfailed in 927.35s (0:15:27)

With MPI (2, 4 and 8 cores):

$ mpiexec -n 2 pytest -q  # don't mix with pytest-xdist!
...

All these tests run nightly on a server somewhere.

Example: gpaw/test/something/test_thing.py:

from gpaw import GPAW

def test_stuff(in_tmp_dir, gpw_files):
    """Test some feature that needs a GPAW object.

    Also write some files and make a mess.  Pytest will clean up.
    """
    calc = GPAW(gpw_files['bcc_li_lcao'])
    ...

Special GPAW-fixtures: gpaw/test/conftest.py

Doctests:

def func(x: int) -> int:
    """Silly function.

    >>> func(1)
    2
    """
    return x + 1