pygmt icon indicating copy to clipboard operation
pygmt copied to clipboard

Use the pytest-randomly plugin to run tests in random order

Open seisman opened this issue 1 year ago • 4 comments

Description of proposed changes

Fixes #

Reminders

  • [ ] Run make format and make check to make sure the code follows the style guide.
  • [ ] Add tests for new features or tests that would have caught the bug that you're fixing.
  • [ ] Add new public functions/methods/classes to doc/api/index.rst.
  • [ ] Write detailed docstrings for all functions/methods.
  • [ ] If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • [ ] If adding new functionality, add an example to docstrings or tutorials.
  • [ ] Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

seisman avatar Jan 01 '24 08:01 seisman

@weiji14 Randomly running the tests finds a minor bug in PR #2774. Some tests like below fail:

______________________ test_virtualfile_from_matrix_slice ______________________

dtypes = ['int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', ...]

    def test_virtualfile_from_matrix_slice(dtypes):
        """
        Test transforming a slice of a larger array to virtual file dataset.
        """
        shape = (10, 6)
        for dtype in dtypes:
>           full_data = np.arange(shape[0] * shape[1], dtype=dtype).reshape(shape)
E           TypeError: data type 'int8[pyarrow]' not understood

The failures are because dtypes is a list and is mutable, so changes in dtypes affect all later tests: https://github.com/GenericMappingTools/pygmt/blob/925e90e71c4f9da82969e3b01c5c33bd96894312/pygmt/tests/test_clib_virtualfiles.py#L328-L329

seisman avatar Jan 01 '24 08:01 seisman

The failures are because dtypes is a list and is mutable, so changes in dtypes affect all later tests:

Good spotting, I opened a PR at #2941 to fix this.

weiji14 avatar Jan 02 '24 05:01 weiji14