Skip to content

Migrate to Pytest #368

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

Merged
merged 4 commits into from
Feb 14, 2017
Merged

Migrate to Pytest #368

merged 4 commits into from
Feb 14, 2017

Conversation

vmuriart
Copy link
Contributor

@vmuriart vmuriart commented Feb 8, 2017

What does this implement/fix? Explain your changes.

  • Unittests module requires alot of boilerplate setup to get running. Pytest the process of unittest writing within python making it easier for new contributors to add tests.
  • Any test can be run by itself again, instead of having to run the entire test suite.

Does this close any currently open issues?

N/A

Any other comments?

This was the original meant to be part of #329 but decided to separate it out.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@vmuriart vmuriart self-assigned this Feb 8, 2017
@vmuriart
Copy link
Contributor Author

vmuriart commented Feb 8, 2017

Also another nice feature is that it has a nicer output

$ python -m pytest
============================= test session starts ==============================
platform linux -- Python 3.3.5, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
rootdir: /home/travis/build/pythonnet/pythonnet, inifile: setup.cfg
collected 360 items 
src/tests/test_array.py ........................................
src/tests/test_callback.py ..
src/tests/test_class.py ..................
src/tests/test_compat.py ................
src/tests/test_constructors.py ....
src/tests/test_conversion.py ....................
src/tests/test_delegate.py .................
src/tests/test_docstring.py ...
src/tests/test_engine.py .ss
src/tests/test_enum.py ...............
src/tests/test_event.py ............................
src/tests/test_exceptions.py .........................
src/tests/test_field.py ..............................
src/tests/test_generic.py .................
src/tests/test_import.py .
src/tests/test_indexer.py .............................
src/tests/test_interface.py ....
src/tests/test_method.py ........................................
src/tests/test_module.py ...........................
src/tests/test_property.py ..........
src/tests/test_recursive_types.py .
src/tests/test_subclass.py sssss.
src/tests/test_sysargv.py .
src/tests/test_thread.py ...

vs

$ python src/tests/runtests.py
Load clr import hook
.................................................................................................................................s.............................................................................................................................................................................................................................s.ssssss.
----------------------------------------------------------------------
Ran 360 tests in 2.367s
OK (skipped=8)

@codecov
Copy link

codecov bot commented Feb 8, 2017

Codecov Report

Merging #368 into master will increase coverage by 0.09%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #368      +/-   ##
==========================================
+ Coverage   63.08%   63.18%   +0.09%     
==========================================
  Files          61       61              
  Lines        5239     5239              
  Branches      876      876              
==========================================
+ Hits         3305     3310       +5     
+ Misses       1715     1709       -6     
- Partials      219      220       +1
Impacted Files Coverage Δ
src/runtime/pythonexception.cs 64.28% <ø> (-1.79%)
src/runtime/assemblymanager.cs 89.78% <ø> (+1.07%)
src/runtime/moduleobject.cs 84.39% <ø> (+2.31%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a5d325f...76aa731. Read the comment docs.

Copy link
Member

@filmor filmor left a comment

Choose a reason for hiding this comment

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

This is a very good idea. We just need to fix the conda recipe, too.

MANIFEST.in Outdated
@@ -0,0 +1,20 @@
graft docs
Copy link
Member

Choose a reason for hiding this comment

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

What is this file for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to remove that commit/file. Its supposed to replace the _get_source_files in setup.py.
I didn't get around to testing it though. Removing it fixes the conda recipe.

Let me fix that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question

@vmuriart
Copy link
Contributor Author

vmuriart commented Feb 8, 2017

@filmor @denfromufa conda recipe fixed.
I wrote that MANIFEST.in a while back, it was referring to a docs folder we had i think.

@vmuriart
Copy link
Contributor Author

vmuriart commented Feb 8, 2017

All builds finished, none of them had the conda.recipe build error from the manifest. Looks like we are good to merge then?

@den-run-ai
Copy link
Contributor

den-run-ai commented Feb 9, 2017

I like the switch to pytest, can you give 1-2 days to review this and test locally? @vmuriart

@vmuriart
Copy link
Contributor Author

vmuriart commented Feb 9, 2017

Sure. Test wise, nothing changed other than indent level.
Have you tried using tox for testing? It will let you run against all interpreters you have installed.

@den-run-ai
Copy link
Contributor

den-run-ai commented Feb 9, 2017 via email

@vmuriart
Copy link
Contributor Author

vmuriart commented Feb 9, 2017

You can configure it for it; though idk if pythonnet would have any issues w it.

@vmuriart vmuriart removed the decision label Feb 13, 2017
@vmuriart
Copy link
Contributor Author

@denfromufa did you get a chance to finish testing?

@den-run-ai
Copy link
Contributor

den-run-ai commented Feb 13, 2017 via email

pytest on travis initially required `sudo=required` otherwise failed.
Without the sudo flag pytest wasn't being upgraded. Needed to force
upgrade.

pytest-dev/pytest#2240
Needs local imports to work.
Conversion done with unittests2pytests and a couple regex
Control settings for some add-ons like pytest
@vmuriart vmuriart merged commit 76aa731 into pythonnet:master Feb 14, 2017
vmuriart added a commit that referenced this pull request Feb 14, 2017
@vmuriart vmuriart deleted the pytest branch February 14, 2017 11:20
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.

3 participants