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

Pytest target #1493

Merged
merged 14 commits into from Sep 18, 2013
Merged

Pytest target #1493

merged 14 commits into from Sep 18, 2013

Conversation

joshmoore
Copy link
Member

Enable all pytests (OmeroPy/test) including gatewaytests via the "integration" target. This means all of the following should now run Python:

 ome.git$ ./build.py test-integration
 ome.git$ cd components/tools/OmeroPy
 OmeroPy$ ../../../build.py integration
 OmeroPy$ ../../../build.py python-integration

@bpindelski
Copy link

@joshmoore If you think this PR fixes http://trac.openmicroscopy.org.uk/ome/ticket/11431, could the ticket be closed? If there is any more work needed, I'm happy to contribute - please add to the ticket. Thanks.

@joshmoore
Copy link
Member Author

Agreed. Closed the ticket. A looming question: how do we select unit tests? /cc @ximenesuk

@ximenesuk
Copy link
Contributor

The simplest way would be to include unit tests in a specific directory under OmeroPy/test. It could also be done using naming or markers but that is probably more complex.

@ximenesuk
Copy link
Contributor

Testing this:

ome.git$ ./build.py test-integration

results in the following usage message

jrs-macbookpro-25031:ome cblackburn$ ./build.py test-integration
Buildfile: /Users/cblackburn/Work/repos/ome/build.xml

check-ivy:
:: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ ::
:: loading settings :: file = /Users/cblackburn/Work/repos/ome/etc/ivysettings.xml

test-integration:
:: loading settings :: file = /Users/cblackburn/Work/repos/ome/etc/ivysettings.xml
Entering /Users/cblackburn/Work/repos/ome/components/xsd-fu...
Entering /Users/cblackburn/Work/repos/ome/components/tools/OmeroCpp...
Entering /Users/cblackburn/Work/repos/ome/components/tools/OmeroFS...

python-integration:
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
WARNING: '' not a valid package name; please use only.-separated package names in setup.py
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help
error: option --junitxml not recognized
Result: 1
Entering /Users/cblackburn/Work/repos/ome/components/tools/OmeroPy...

the tests then proceed to run.

 ome.git$ cd components/tools/OmeroPy
 OmeroPy$ ../../../build.py integration
 OmeroPy$ ../../../build.py python-integration

both run the tests without the usage message. I've not yet run any integration tests to conclusion to confirm whether a junitxml file is produced in ether case.

OmeroFS and all other python-based tools components will
need the PyTest class as a command in their setup.py.
@joshmoore
Copy link
Member Author

With the latest two commits, most of this is fixed. However, OmeroFS is going to require more work, that may or may not be doable here.

Move unit tests

components/tools/OmeroPy$ ./setup.py test -s test/unit/
...
======================================================= test session starts =======================================================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5
collected 89 items 

test/unit/test_clients.py .......
test/unit/test_config.py ...........
test/unit/test_ext.py .
test/unit/test_model.py .......................
test/unit/test_parameters.py ......................
test/unit/test_permissions.py ...
test/unit/test_rtypes.py ...........
test/unit/test_tempfiles.py ...........

==================================================== 89 passed in 0.36 seconds ====================================================
(ome1)jamoore@blue:/opt/ome2/components/tools/OmeroPy$ 

Refactoring PyTest

...components/tools/OmeroFS$ ../../../build.py python-integration

============================= test session starts ==============================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5 -- /opt/venv/ome1/bin/python
collecting ... collected 0 items
 generated xml file: /opt/ome2/components/tools/OmeroFS/target/reports/junit-results.xml 
===============================  in 0.00 seconds ===============================

@joshmoore
Copy link
Member Author

Moved final test setups to PyTest. Only remaining files that won't be run by PyTest are:

components/tools/OmeroPy$ git ls-files test | grep -v test_ | grep -v __init__
test/gatewaytest/conftest.py
test/gatewaytest/library.py
test/integration/client_ctors.cfg
test/integration/helpers.py
test/integration/library.py
test/integration/scriptsharness/definition.cfg
test/integration/scriptsharness/definition.py
test/integration/scriptsharness/harness.py
test/integration/scriptsharness/simple_script.cfg
test/integration/scriptsharness/simple_script.py
test/integration/tablestest/service-reference-dev_4_4_5.h5.bz2
test/unit/clitest/mocks.py
test/unit/tablestest/library.py

Of these, only scriptsharness should need further work.

@joshmoore
Copy link
Member Author

With the last commit, unit tests are now run properly by build.py. Both with and without -DTEST=somepath:

/opt/ome2/components/tools/OmeroPy$ ../../../build.py python-test -DTEST=test/unit/clitest/test_import.py 
Buildfile: /opt/ome2/components/tools/OmeroPy/build.xml
Entering /opt/ome2/components/tools/OmeroPy...

python-test:
Entering /opt/ome2/components/tools/OmeroPy...

python-test-single:
...
============================= test session starts ==============================
platform linux2 -- Python 2.7.4 -- pytest-2.3.5 -- /opt/venv/ome1/bin/python
collecting ... collected 1 items
test/unit/clitest/test_import.py:31: TestImport.testDropBoxArgs PASSED
 generated xml file: /opt/ome2/components/tools/OmeroPy/target/reports/junit-results.xml 
=========================== 1 passed in 0.15 seconds ===========================
Entering /opt/ome2/components/tools/OmeroPy...

BUILD SUCCESSFUL
Total time: 0 seconds

@joshmoore
Copy link
Member Author

Unless there's something very grievous here, I'm assuming that's it for me. Happy to have this merged and then pass off to @ximenesuk for either fixing or marking the failing unit tests.

@joshmoore
Copy link
Member Author

Note: I also didn't move around the OmeroFS test files which will need to be done to not have them missed by setup.py test -s test/

@ximenesuk
Copy link
Contributor

I noticed in testing this that:

../../../build.py python-integration

seemed to also run the tests under OmeroPy/test/unit

@joshmoore
Copy link
Member Author

That's always been my preference so that the complete suite on integration. Open to suggestions.

@ximenesuk
Copy link
Contributor

I assume you mean, "... so that the complete suite is run on integration." If so that's fine. I just found the name a little confusing. I guess I would have expected something like python-test, python-unit and python-integration where the first is a union of the second two. But as long as the targets are (eventually) documented somewhere I'm easy.

@joshmoore
Copy link
Member Author

Agreed. (Along with the naming of the junit results file discussed today with @bpindelski)

@joshmoore
Copy link
Member Author

Jabber-based 👍 from @ximenesuk

joshmoore added a commit that referenced this pull request Sep 18, 2013
@joshmoore joshmoore merged commit f08f73d into ome:dev_4_4 Sep 18, 2013
@ximenesuk
Copy link
Contributor

--rebased-to #1524

@joshmoore joshmoore deleted the pytest-target branch January 23, 2014 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants