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

Add test for API Python snippets #9615

Closed

Conversation

arnaud-morvan
Copy link
Contributor

@arnaud-morvan arnaud-morvan commented Mar 23, 2019

Description

Add unittest.TestCase that use native python doctest module with custom parser to test API Python snippets.

In this PR, only QgsHighlight is tested, more classes might be tested later using INCLUDE variable.

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

  • Commit messages are descriptive and explain the rationale for changes
  • Commits which fix bugs include fixes #11111 in the commit message next to the description
  • Commits which add new features are tagged with [FEATURE] in the commit message
  • Commits which change the UI or existing user workflows are tagged with [needs-docs] in the commit message and contain sufficient information in the commit message to be documented
  • I have read the QGIS Coding Standards and this PR complies with them
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • New unit tests have been added for core changes
  • I have run the scripts/prepare-commit.sh script before each commit

@@ -18,6 +18,9 @@ for highlighting features or geometries on a map canvas.

.. code-block:: python

mapCanvas = iface.mapCanvas()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to move this bit to a "setup" section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When running them, snippets come directly from compiled Python API docstrings (.so), so i don't want to put setup section in the docstring, because it is readable by IDE and more.
I would prefer move this specific line to the python test file 'test_docstrings.py" and mapCanvas would be passed as a global variable like iface.

@nyalldawson
Copy link
Collaborator

This is great work, will be VERY useful!

@nyalldawson nyalldawson added Documentation Changes to Documentation, README, INSTALL, etc Chore GitHub and other CI infrastructure changes labels Mar 31, 2019
@nyalldawson nyalldawson added this to the 3.8 milestone Mar 31, 2019
@stale
Copy link

stale bot commented Apr 14, 2019

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Apr 14, 2019
@luipir
Copy link
Contributor

luipir commented Apr 15, 2019

This is great work, will be VERY useful!

is it a an approve?

IMHO the test works if there are really snippets in docstrings of qgis._core and qgis._gui modules. Are there already available @arnaud-morvan ?

@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Apr 15, 2019
@arnaud-morvan
Copy link
Contributor Author

Yes, the test execute snippets from docstrings in qgis._core and qgis._gui modules (after compilation).
For now it only execute the code snippet from QgsHighlight.
Concerning review comment from @nyalldawson, I could declare mapCanvas in unit test_docstrings.py as unit test module globals are shared with doctest, but I don't want to put test setup sections in API docstrings.

@stale
Copy link

stale bot commented May 3, 2019

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label May 3, 2019
@stale
Copy link

stale bot commented May 10, 2019

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@stale stale bot closed this May 10, 2019
@luipir luipir reopened this May 12, 2019
@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label May 12, 2019
@nyalldawson nyalldawson modified the milestones: 3.8, 3.8.0 May 19, 2019
@stale
Copy link

stale bot commented Jun 2, 2019

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jun 2, 2019
@stale
Copy link

stale bot commented Jun 10, 2019

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@stale stale bot closed this Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chore GitHub and other CI infrastructure changes Documentation Changes to Documentation, README, INSTALL, etc stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants