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

Introduce Pytest, Tox, Coverage #19

Merged
merged 3 commits into from
Sep 30, 2014
Merged

Introduce Pytest, Tox, Coverage #19

merged 3 commits into from
Sep 30, 2014

Conversation

dbrgn
Copy link
Member

@dbrgn dbrgn commented Sep 29, 2014

Fixes #13.

Still work in progress. Qemu on Travis is very slow :/

The question is whether we actually need Qemu with a real server, or if we can go with mocking one. Then we could get rid of the Qemu setup.

from setuptools import setup, find_packages
from minecraft import meta

readme = io.open('README.rst', mode='r', encoding='utf8').read()
Copy link
Member

Choose a reason for hiding this comment

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

This can use with open().

Copy link
Member Author

Choose a reason for hiding this comment

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

The default open is not a good idea because it does not always handle encoding correctly, see strongswan/swidGenerator#35. If the system has a terminal which is not set to UTF-8, it could cause problems.

Using a context manager is a good idea though.

@ghickman
Copy link
Member

@dbrgn – This is a good start but I don't think we need to target 3.4 as Raspbian doesn't ship it yet. Thanks for making the change to Tox!

@doismellburning
Copy link
Member

That said, I think we still want to work with 3.4 (for when Raspbian does ship it), but we need it to work for 3.2 (Wheezy stable)

@dbrgn
Copy link
Member Author

dbrgn commented Sep 30, 2014

That said, I think we still want to work with 3.4 (for when Raspbian does ship it), but we need it to work for 3.2 (Wheezy stable)

Exactly, 3.2 should be the main goal right now, but eventually the library will be used under Python 3.4.

I'd suggest we keep the versions 3.3 and 3.4 in tox, but remove them from Travis, what do you think? (Or we could flag them as allowed failures.)

@ghickman
Copy link
Member

@dbrgn @doismellburning – No I think those are fair points, lets keep both versions in ready for when they're available.

- Tests are run using pytest
- Test environments are set up using tox
- Right now, Travis-CI is set up using a Qemu installation, in which
  tox is run
- Coverage is measured
- Coding guidelines are enforced
@dbrgn
Copy link
Member Author

dbrgn commented Sep 30, 2014

OK, feedback has been integrated and the branch has been rebased.

Right now there's a build matrix on Travis with Python 2.7 and 3.2. There's also a build that does coverage testing, with an allowed failure. In there we could add a tool like Coveralls.

img

The tests pass on Python 2.7 and fail on all Python 3 versions.

In the "cov" build you can see an ASCII coverage report:

img

@doismellburning
Copy link
Member

That Py3 failure looks...fun :s

@pozorvlak
Copy link
Contributor

Yay for working CI builds! OTOH, it's a bit disappointing that it fails on
the Python dialect we're supposed to be targeting...

As for the QEMU thing: that was me following instructions from a random
blog post in a code sprint. We're currently doing a ridiculous number of
levels of virtualisation - QEMU within an ARM VM which is almost certainly
being simulated on x86 hardware - and as anyone who's seen Inception
knows, running a VM within a VM within a VM makes everything
veeeerrrrrryyyyy ssssslllllllooooooowwwwwww. If there's a faster way of
testing in our expected deployment environment, that would be awesome;
however, I'm reluctant to go a test setup that doesn't attempt to run at
least a few tests against the actual binary blob.

On Tue, Sep 30, 2014 at 10:26 AM, Danilo Bargen [email protected]
wrote:

OK, feedback has been integrated and the branch has been rebased.

Right now there's a build matrix on Travis with Python 2.7 and 3.2.
There's also a build that does coverage testing, with an allowed failure.
In there we could add a tool like Coveralls.

[image: img]
https://camo.githubusercontent.com/6b89598410c052f0366e3ac665c5713f50acc2d9/687474703a2f2f746d702e646272676e2e63682f73637265656e73686f74732f32303134303933305f3131323330332e706e67

The tests pass https://travis-ci.org/py3minepi/py3minepi/jobs/36648632
on Python 2.7 and fail
https://travis-ci.org/py3minepi/py3minepi/jobs/36648633 on all Python 3
versions.

In the "cov" build you can see an ASCII coverage report:

[image: img]
https://camo.githubusercontent.com/fe6e68de1f74ac81bb3ae7f6288e35d5cae56c42/687474703a2f2f746d702e646272676e2e63682f73637265656e73686f74732f32303134303933305f3131323532332e706e67


Reply to this email directly or view it on GitHub
py3minepi/py3minepi#19 (comment).

@doismellburning
Copy link
Member

Yeah, it's slow and tedious but I definitely like the idea of Actual Realistic Testing - not sure I have any bright ideas about good ways to speed it though...

(DIY Jenkins testing against pre-built emulator images? That way at least we're pre-loading the work from most of https://github.com/py3minepi/py3minepi/blob/master/.travis-ci.sh, otoh that's a tedious maintenance requirement - I think I'd rather just have slower tests...)

@doismellburning
Copy link
Member

Anyway this looks good. Can I confirm that this is a net improvement, i.e. some tests now pass whereas none did previously?

@pozorvlak
Copy link
Contributor

+1 on it being a net improvement, and +1 for the overall idea of the change.

@ghickman
Copy link
Member

I'm in agreement with @pozorvlak, it's a net improvement and adds some of the items we discussed in #14.

@dbrgn
Copy link
Member Author

dbrgn commented Sep 30, 2014

That Py3 failure looks...fun :s

Probably some issue with identity comparison. But that test doesn't really matter anyways. Most of the code is still untested.

If there's a faster way of testing in our expected deployment environment, that would be awesome

Yes, mocking. But mocking is always based on assumptions. We can just test what gets sent to Minecraft, not what Minecraft does with it.

however, I'm reluctant to go a test setup that doesn't attempt to run at least a few tests against the actual binary blob.

While that sounds good, how do we actually write the assertions? There's no way to test whether a set_block command actually created a block. And Minecraft does not return any output on errors. So basically there's no way to test any assertions using the Minecraft binary.

@pozorvlak
Copy link
Contributor

Why can't we send getBlockWithData calls to check if the block now has
the expected type?

On Tue, Sep 30, 2014 at 12:29 PM, Danilo Bargen [email protected]
wrote:

That Py3 failure looks...fun :s

Probably some issue with identity comparison. But that test doesn't really
matter anyways. Most of the code is still untested.

If there's a faster way of testing in our expected deployment environment,
that would be awesome

Yes, mocking. But mocking is always based on assumptions. We can just test
what gets sent to Minecraft, not what Minecraft does with it.

however, I'm reluctant to go a test setup that doesn't attempt to run at
least a few tests against the actual binary blob.

While that sounds good, how do we actually write the assertions? There's
no way to test whether a set_block command actually created a block. And
Minecraft does not return any output on errors. So basically there's no way
to test any assertions using the Minecraft binary.


Reply to this email directly or view it on GitHub
py3minepi/py3minepi#19 (comment).

@dbrgn
Copy link
Member Author

dbrgn commented Sep 30, 2014

Oh, true, we can do that... Sorry for forgetting :) It's an integration though, not a unit test. For unit tests, we should use mocking. It's faster anyways.

In that case I'll merge this.

dbrgn added a commit that referenced this pull request Sep 30, 2014
Introduce Pytest, Tox, Coverage
@dbrgn dbrgn merged commit 456702b into master Sep 30, 2014
@dbrgn dbrgn deleted the pytest branch September 30, 2014 13:17
@doismellburning
Copy link
Member

Please never again merge your own pull request, thanks

@dbrgn
Copy link
Member Author

dbrgn commented Sep 30, 2014

@doismellburning I thought the three confirming comments above were a "good to merge". But in that case I'll leave it to others in the future :)

@pozorvlak
Copy link
Contributor

@dbrgn: absolutely, anything that touches the Minecraft binary is an
integration test. But we should do integration tests in addition to our
unit tests, and the place to do so is in CI :-)

On Tue, Sep 30, 2014 at 2:20 PM, Danilo Bargen [email protected]
wrote:

@doismellburning https://github.com/doismellburning I thought the three
confirming comments above were a "good to merge". But in that case I'll
leave it to others in the future :)


Reply to this email directly or view it on GitHub
py3minepi/py3minepi#19 (comment).

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.

Testing Framework
4 participants