py3minepi / py3minepi-legacy

Original attempt to port Minecraft Pi to Python 3
https://github.com/py3minepi/py3minepi
Other
25 stars 7 forks source link

API compatibility tests #37

Closed doismellburning closed 10 years ago

doismellburning commented 10 years ago

http://www.raspberrypi.org/documentation/usage/minecraft/ transcribed into code (ish)

Plus a whole bunch of reversion needed to fix compatibility breakages

doismellburning commented 10 years ago

Currently blocked on #38

dbrgn commented 10 years ago

Good idea to rename minecraft to mcpi.

We could (and should) keep the newer and the compat API in two totally separate packages.

doismellburning commented 10 years ago

So, shall I kick off a Minecraft server in .travis-ci.sh or is that a terrible idea? (I say this; I'm about to give it a try...)

dbrgn commented 10 years ago

You can try whether it even works (did someone do that yet?). I did an attempt with emulating the Raspberry Pi once, and IIRC Minecraft did not run correctly. But maybe this qemu script works better :)

doismellburning commented 10 years ago

Running mock_server.py with these tests results in woe and suffering that I have yet to debug, except so far as to want to bin mock_server

doismellburning commented 10 years ago

I mocked all the things, and then this passed on the code from 6eeb804 (i.e. pre-sprint); looks like I'm going to need to revert/fix a bunch of changes from then

doismellburning commented 10 years ago

Tests should pass now, huzzah! (That is to say, they do locally under Python 2.7; I haven't tried 3)

It looks like a bunch of stuff got broken at the sprint; I've done some slightly heavy-handed reversion, because not breaking teachers' existing tutorials is a massive priority

doismellburning commented 10 years ago

Note that this is quite insufficient - it doesn't actually test that the commands we're sending are in any way valid (see my monkey-patching) BUT it took nontrivial work to get (back) to just this amount of working-ness, so I'd call this a significant net improvement

doismellburning commented 10 years ago

Well, it passes on my machine but I'm baffled as to why; time for more monkeypatching!

doismellburning commented 10 years ago

So close. Failed because an example uses xrange which isn't in Py3k

I consider it acceptable to change that test to use range, rather than introduce some xrange backwards compatibility thing, because this is a Python change

(Relatedly, I am saddened by Python 3 dropping xrange, but that's out of scope for this...)

dbrgn commented 10 years ago

(Relatedly, I am saddened by Python 3 dropping xrange, but that's out of scope for this...)

Why? In Python 3 range returns a generator by default, so no xrange is needed anymore. It's more consistent.

We could add a simple compat.py module that does things like

try:
    xrange = xrange
except NameError:
    xrange = range
doismellburning commented 10 years ago

Because needless compatibility breakage makes me sad

Yes we could do that, but I do not want to, because it would seem contrary to the goal of encouraging Python 3 (even though I happen to find that change infuriating)

dbrgn commented 10 years ago

Well, if a user uses Python 3 he can still use range directly. The compat xrange would only be used internally.

OTOH, xrange is only useful to reduce memory consumption. For small lists it is even slower than range if I remember correctly.

doismellburning commented 10 years ago

Please don't assume "he"

dbrgn commented 10 years ago

You're right, I try not to, but it's a bad habit :) (Btw, the thing about range being faster was wrong. I had generator expressions vs list comprehensions in mind.)

doismellburning commented 10 years ago

ghickman commented 10 years ago

10 points for amazing giffing!