py3minepi/py3minepi — pull request #22 by hashbangstudio (2014-10-01 15:28:45+00:00)
Title: Add examples and tests

Making pull request to add examples and tests.

We had a set of examples we used to show what you could do with the original API, so these have been ported to Python 3 API and added in folder `examples`.
Examples are heavily commented as they were meant as stand-alone teaching aid/reference, with guide to be written later.

We've added a set of block data enumerations so you can control the colour of wool blocks, etc. Enums in `minecraft/blockData.py`

We also had a set of unittest module tests for the original API, so again ported to Python 3. In folder `tests/test_*.py`
py.test can use unittest files as well, so we thought it better to have some tests now and can be made py.test style later.

Passes with py.test-3.2 (platform linux2 -- Python 3.2.3 -- py-1.4.25 -- pytest-2.6.3 plugins: pep8, cache ) with minecraft-pi running on my Pi

All examples worked last time I tested but some bugs may still be there as testing of examples was limited to a basic successful run. (I created a symbolic link `mcpi` from python 3.2 modules directory to the `minecraft ` directory of local repository to ensure they could run rather than adding to path)

Note: we have had to make a few changes to the API to make everything work:

1. With the removal of the flatten functions, made it necessary to wrap some string parameters to `send` function in a one element tuple, otherwise itertools puts comma between each letter.

2. Updated to newer `__eq__` and functools comparison overrides not `__cmp__`

3. Suggest (as in this request) move to use IntEnum from Python 3.4 as this allows direct integer comparison rather than having to always use myEnum.value in comparisons. We think this is a good idea for novices.

4. We made length and lengthSqr of Vec3 into properties as it means usage is the same as coordinates.

5. Suggest (as used in this request) that move to single import for Enum as has been back ported.
* Can be installed for Python 3.2 on Pi. `python3-pip` available in Raspbian repos
* Then can easily install enums with `pip-3.2 enum34`

Hopefully of some use :)

If people want only sections/parts of this, let us know and we can do as separate pull requests.