Commit Graph

35 Commits

Author SHA1 Message Date
joodicator 33293a2395 Fix: Travis pypy test environment fails to install 2021-12-16 20:51:46 +01:00
joodicator bf49006553 Add support for Minecraft 1.18 and 1.18.1. 2021-12-16 19:39:13 +01:00
joo 969419da3f Fix: non-monotonic protocol versions are not correctly handled
After 1.16.3, Mojang started publishing snapshot, pre-release and release
candidate versions of Minecraft with protocol version numbers of the form
`(1 << 30) | n' where 'n' is a small non-negative integer increasing with each
such version; the release versions continued to use the old format. For
example, these are the last 8 published Minecraft versions as of this commit:

release           1.16.3      uses protocol version 753
pre-release       1.16.4-pre1 uses protocol version 1073741825 == (1 << 30) | 1
pre-release       1.16.4-pre2 uses protocol version 1073741826 == (1 << 30) | 2
release candidate 1.16.4-rc1  uses protocol version 1073741827 == (1 << 30) | 3
release           1.16.4      uses protocol version 754
snapshot          20w45a      uses protocol version 1073741829 == (1 << 30) | 5
snapshot          20w46a      uses protocol version 1073741830 == (1 << 30) | 6
snapshot          20w48a      uses protocol version 1073741831 == (1 << 30) | 7

This means that protocol versions no longer increase monotonically with respect
to publication history, a property that was assumed to hold in much of
pyCraft's code relating to support of multiple protocol versions. This commit
rectifies the issue by replacing any comparison of protocol versions by their
numerical value with a comparison based on their publication time.

Newly defined is the dictionary `minecraft.PROTOCOL_VERSION_INDICES', which
maps each known protocol version to its index in the protocol chronology. As
such, the bound method `minecraft.PROTOCOL_VERSION_INDICES.get` can be used as
a key function for the built-in `sorted`, `min` and `max` functions to collate
protocol versions chronologically.

Two utility functions are provided for direct comparison of protocol versions:
    `minecraft.utility.protocol_earlier` and
    `minecraft.utility.protocol_earlier_eq`.

Additionally, four methods are added to the `ConnectionContext` type to ease
the most common cases where the protocol of a given context must be compared to
a given version number:
    `minecraft.connection.ConnectionContext.protocol_earlier`,
    `minecraft.connection.ConnectionContext.protocol_earlier_eq`,
    `minecraft.connection.ConnectionContext.protocol_later` and
    `minecraft.connection.ConnectionContext.protocol_later_eq`.
2020-12-02 15:11:39 +01:00
joo b79f8b30eb Remove support for Python 2.7 2020-08-17 07:10:10 +02:00
joo b38adc1aa1 Add pre-release versions between 1.14.4 and 1.15.1; update test config 2020-01-08 16:15:42 +01:00
joodicator 7b1567c352 Improve test coverage wrt protocol versions; other fixes/improvements
Improvements to the test suite:
* List release version names and numbers in minecraft/__init__.py.
* Make some tests, which previously ran for *all* protocol versions,
  run only for release protocol versions (to improve test performance).
* Make some tests, which previously ran only for the latest protocol
  version, run for all release protocol versions (to improve coverage).
* Print each protocol version being tested to the debug log, to help
  identify sources of errors.
* Use the `nose-timer' plugin to show the run time of each test.

Fix errors revealed by increased test coverage:
* Fix: SoundEffectPacket.Pitch is not serialised correctly for early
  protocol versions.
* Fix: handleExceptionTest finishes later than necessary because
  the test overrode an exception handler used internally by
  `_FakeServerTest', causing the server thread to time out after 4s.
* Add support for multiple exception handlers in `Connection'
  (required for the above).

Improvements to data descriptors:
* Make syntax of property declarations more consistent/Pythonic.
* Factor the definition of several aliasing properties into the
  utility methods `attribute_alias' and `multi_attribute_alias',
  which construct suitable data descriptors.
* Define and use the named tuple `Direction' for (pitch, yaw) values.
2019-05-14 18:41:58 +02:00
joodicator 612fa8e324 Add support for Minecraft 18w43a to 1.14 (protocols 441 to 477)
This commit introduces two backward-incompatible changes which may break
existing code:

(1) `networking.packets.clientbound.play.SpawnObjectPacket.EntityType'
is no longer accessible as an attribute of the the `SpawnObjectPacket'
class: the values now depend on a `ConnectionContext`, and must be
accessed through an instance, or using `SpawnObjectPacket.field_enum'.
See the text of the `AttributeError` raised from the descriptor for
`SpawnObjectPacket.EntityType` for the full details.

(2) For some subclasses of `networking.types.Type', it is necessary to
call the methods `read_with_context' and `send_with_context' instead of
`read' and `send', supplying a `ConnectionContext' for those data types
- currently only `Position` - whose layout depends on it.
2019-05-11 08:43:51 +02:00
joo da46c4553d Remove support for Python 3.3. Add Python 3.6 to autotests as default version. 2018-05-18 06:00:35 +01:00
joo 3fb922b0d1 Require cryptography<2.0 for Python 3.3, as >=2.0 only supports 3.4+. 2018-01-06 19:22:55 +00:00
joo 3f4571d9e9 Update testing configuration:
(1) Add py35 job to Travis.
(2) To address issue #57: run tests that connect to Mojang's auth server exactly once, during the py35 job.
(3) Measure coverage exactly once, during the py35 job; always submit the result to coveralls.
(4) Fix miscellaneous errors in generate_travis_yml.py.
2017-05-19 11:58:14 +01:00
joo bc260b0a91 Add Python 3.6 to supported Python versions. 2017-03-31 13:16:35 +01:00
Ammar Askar b8330a17fd Fix coveralls being broken 2016-08-11 16:49:26 -07:00
joo 3ff7662684 Update tests to match new API. 2016-06-17 22:54:21 +01:00
Jeppe Klitgaard f3ee66b0b9 We now also cover files without tests 2015-04-11 17:43:11 +02:00
Jeppe Klitgaard 0ac27a940c Switched to using pylintrc file instead of command line options.
This was done because we have a lot of messages we want to ignore (disabled-locally, enabled-locally, etc, etc), which would take up a huge amount of messy space in tox.ini.
2015-04-06 15:47:22 +02:00
Jeppe Klitgaard 8bf7620579 Updated coveralls, now it will run even when cover build fails 2015-04-06 02:29:55 +02:00
Jeppe Klitgaard cf344fd7e5 I forgot a dash cause I'm a dumbdumb 2015-04-06 02:03:32 +02:00
Jeppe Klitgaard 59578bbbc5 flake8 test now tests more python files. 2015-04-06 01:59:08 +02:00
Jeppe Klitgaard f631ecd8ba Retiring pylint-full.py, bye bye. 2015-04-06 01:56:50 +02:00
Jeppe Klitgaard 2a8dd11322 Removed pylintrc, its effect does not warrant its existance as of yet 2015-04-06 01:43:01 +02:00
Jeppe Klitgaard fc6529c913 Removed verify-manifest.py - we now deal with check-manifest in tox.ini 2015-04-06 01:38:39 +02:00
Jeppe Klitgaard 70c381d9f4 pylint-full.py should now be windows compatible 2015-04-06 01:36:06 +02:00
Jeppe Klitgaard e31bfb58f0 Now verify-manifest.py is windows-compatible again 2015-04-06 01:25:16 +02:00
Jeppe Klitgaard c35a887e1a Spruced up verify-manifest.py 2015-04-06 00:53:23 +02:00
Jeppe Klitgaard 9a45eec450 Added pylint-full and messed a bit with tox.ini 2015-04-06 00:42:06 +02:00
Ammar Askar 89f788f3ea Remove unused test environment 2015-04-03 09:01:07 +05:00
Ammar Askar d0f6120043 Oops, ignore pylint warnings not errors 2015-04-03 04:29:40 +05:00
Ammar Askar 398050c248 Only execute coveralls on the cover build 2015-04-03 04:15:16 +05:00
Ammar Askar 4dfdb6282b coveralls support 2015-04-03 03:53:13 +05:00
Ammar Askar d3917b42a4 split up pylint into errors and warning runners 2015-04-03 03:13:22 +05:00
Ammar Askar f7ed4da0d0 Platform independent manifest verification 2015-04-02 23:43:03 +05:00
Ammar Askar 4fe5caa7d9 Added an easy encryption test 2015-04-02 22:02:47 +05:00
Jeppe Klitgaard c34d30566f Made some tests for authentication. Still many tests to be made 2015-04-02 00:11:14 +02:00
Jeppe Klitgaard 83a92daf0b Added tox runner for verifying MANIFEST.in and added MANIFEST.in in preparation for pypi 2015-04-01 19:50:16 +02:00
Jeppe Klitgaard ddeaab51d3 Added tox for testing 2015-04-01 17:40:56 +02:00