Skip to content

Move virtualfile-related tests into a separate test file - #2784

Merged
seisman merged 6 commits into
mainfrom
refactor/test-virtualfiles
Oct 31, 2023
Merged

Move virtualfile-related tests into a separate test file#2784
seisman merged 6 commits into
mainfrom
refactor/test-virtualfiles

Conversation

@seisman

@seismanseisman commented Oct 31, 2023

Copy link
Copy Markdown
Member

Description of proposed changes

  • Move virtualfile-related tests into a separate test file
  • Remove an invalid pylint directive

Address #2729 (comment).

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

@seismanseisman changed the title refactor/test virtualfilesMove virtualfile-related tests into a separate test fileOct 31, 2023
@seismanseisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Oct 31, 2023
@seismanseisman added this to the 0.11.0 milestone Oct 31, 2023


@contextmanager
def mock(session, func, returns=None, mock_func=None):

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that the same code is also defined in test_clib.py.

@weiji14weiji14Oct 31, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the typical way of sharing fixtures in pytest would be to put them in conftest.py, but not sure about this contextmanager... We could also just keep that single test_virtual_file_fails test in test_clib.py to avoid duplicating this contextmanager?

@seismanseismanOct 31, 2023

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized the mock function is also used in other files like test_clib_put_matrix.py by from pygmt.tests.test_clib import mock.

This may not be a best practice but it works. Done in d5ef26e.

@seismanseisman added the needs review This PR has higher priority and needs review. label Oct 31, 2023
Comment threadpygmt/tests/test_clib_virtualfiles.py Outdated


@contextmanager
def mock(session, func, returns=None, mock_func=None):

@weiji14weiji14Oct 31, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the typical way of sharing fixtures in pytest would be to put them in conftest.py, but not sure about this contextmanager... We could also just keep that single test_virtual_file_fails test in test_clib.py to avoid duplicating this contextmanager?

Comment threadpygmt/tests/test_clib_virtualfiles.py Outdated
Comment threadpygmt/tests/test_clib_virtualfiles.py Outdated
seismanand others added 2 commits October 31, 2023 15:55
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenanceBoring but important stuff for the core devsskip-changelogSkip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@seisman@michaelgrund@weiji14