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

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

seisman
Copy link
Member

@seisman seisman commented Jan 1, 2024

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 seisman changed the title Run tests randomly Use the pytest-randomly plugin to run tests in randonly order Jan 1, 2024
@seisman seisman changed the title Use the pytest-randomly plugin to run tests in randonly order Use the pytest-randomly plugin to run tests in randomly order Jan 1, 2024
@seisman seisman changed the title Use the pytest-randomly plugin to run tests in randomly order Use the pytest-randomly plugin to run tests in random order Jan 1, 2024
@seisman
Copy link
Member Author

seisman commented Jan 1, 2024

@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:

if find_spec("pyarrow") is not None:
dtypes.extend([f"{dtype}[pyarrow]" for dtype in dtypes])

@weiji14
Copy link
Member

weiji14 commented Jan 2, 2024

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 weiji14 closed this in #2941 Jan 2, 2024
@seisman seisman reopened this Jan 2, 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 this pull request may close these issues.

None yet

2 participants