From c3c886e5c658b999abad947ab8891df1af9d2e7f Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 8 Oct 2019 19:37:32 +0100 Subject: [PATCH 1/6] fix #54; getting a float instead of integer --- aprslib/parsing/mice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aprslib/parsing/mice.py b/aprslib/parsing/mice.py index b79231c..36720d1 100644 --- a/aprslib/parsing/mice.py +++ b/aprslib/parsing/mice.py @@ -187,9 +187,9 @@ def parse_mice(dstcall, body): if match: hexdata, body = match[0] - hexdata = hexdata[1:] # remove telemtry flag - channels = len(hexdata) / 2 # determine number of channels - hexdata = int(hexdata, 16) # convert hex to int + hexdata = hexdata[1:] # remove telemtry flag + channels = int(len(hexdata) / 2) # determine number of channels + hexdata = int(hexdata, 16) # convert hex to int telemetry = [] for i in range(channels): From 2f0f74a06d265ca62c9b80471098cbf3e28dfd78 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 8 Oct 2019 19:42:44 +0100 Subject: [PATCH 2/6] fix SyntaxWarning for py38 and remove py33 on travis --- .travis.yml | 1 - aprslib/parsing/mice.py | 10 +++++----- tests/test_parse_comment_telemetry.py | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3e5346a..c130959 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python sudo: false python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" diff --git a/aprslib/parsing/mice.py b/aprslib/parsing/mice.py index 36720d1..64c03c1 100644 --- a/aprslib/parsing/mice.py +++ b/aprslib/parsing/mice.py @@ -140,15 +140,15 @@ def parse_mice(dstcall, body): # apply position ambiguity # routines adjust longitude to center of the ambiguity box - if posambiguity is 4: + if posambiguity == 4: lngminutes = 30 - elif posambiguity is 3: + elif posambiguity == 3: lngminutes = (math.floor(lngminutes/10) + 0.5) * 10 - elif posambiguity is 2: + elif posambiguity == 2: lngminutes = math.floor(lngminutes) + 0.5 - elif posambiguity is 1: + elif posambiguity == 1: lngminutes = (math.floor(lngminutes*10) + 0.5) / 10.0 - elif posambiguity is not 0: + elif posambiguity != 0: raise ParseError("Unsupported position ambiguity: %d" % posambiguity) longitude += lngminutes / 60.0 diff --git a/tests/test_parse_comment_telemetry.py b/tests/test_parse_comment_telemetry.py index 91b7ab8..59447b4 100644 --- a/tests/test_parse_comment_telemetry.py +++ b/tests/test_parse_comment_telemetry.py @@ -47,7 +47,7 @@ class ParseCommentTelemetry(unittest.TestCase): bits = None - if len(vals) is 5 and randint(1, 10) > 5: + if len(vals) == 5 and randint(1, 10) > 5: bits = "{0:08b}".format(randint(0, 255))[::-1] testData = self.genTelem(i, vals, bits) From 512d97122c913bb84d0b50762a48ecb2ab4a86c9 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Tue, 8 Oct 2019 20:02:19 +0100 Subject: [PATCH 3/6] fix StopIteration breaking a test on py37+ --- tests/test_IS.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_IS.py b/tests/test_IS.py index 26b1683..00326c1 100644 --- a/tests/test_IS.py +++ b/tests/test_IS.py @@ -47,6 +47,9 @@ class TC_IS(unittest.TestCase): f.write("something") f.close() + class BreakBlocking(Exception): + pass + self.m.ReplayAll() self.ais.sock = mox.MockAnything() # part 1 - conn drop before setblocking @@ -74,7 +77,7 @@ class TC_IS(unittest.TestCase): self.ais.sock.fileno().AndReturn(fdr) self.ais.sock.recv(mox.IgnoreArg()).AndReturn(b"b\r\n"*3) self.ais.sock.fileno().AndReturn(fdr) - self.ais.sock.recv(mox.IgnoreArg()).AndRaise(StopIteration) + self.ais.sock.recv(mox.IgnoreArg()).AndRaise(BreakBlocking) mox.Replay(self.ais.sock) next_method = '__next__' if sys.version_info[0] >= 3 else 'next' @@ -92,8 +95,9 @@ class TC_IS(unittest.TestCase): for line in self.ais._socket_readlines(): self.assertEqual(line, b'a') # part 5 - for line in self.ais._socket_readlines(blocking=True): - self.assertEqual(line, b'b') + with self.assertRaises(BreakBlocking): + for line in self.ais._socket_readlines(blocking=True): + self.assertEqual(line, b'b') mox.Verify(self.ais.sock) From 097ba853c496a510020d2d992f3843d6f0f9bbf4 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 26 Oct 2019 20:17:21 +0100 Subject: [PATCH 4/6] bump v0.6.37 --- aprslib/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aprslib/__init__.py b/aprslib/__init__.py index 1c7fae1..f9e71c6 100644 --- a/aprslib/__init__.py +++ b/aprslib/__init__.py @@ -41,8 +41,8 @@ from datetime import date as _date __date__ = str(_date.today()) del _date -__version__ = "0.6.46" -version_info = (0, 6, 46) +__version__ = "0.6.47" +version_info = (0, 6, 47) __author__ = "Rossen Georgiev" __all__ = ['IS', 'parse', 'passcode'] From 55d85c6bc54203afd9eee836703f2f48ff8b6af3 Mon Sep 17 00:00:00 2001 From: Rossen <2720787+rossengeorgiev@users.noreply.github.com> Date: Thu, 21 Jan 2021 23:27:50 +0000 Subject: [PATCH 5/6] Move to Github Actions (#59) --- .coveragerc | 9 ++++ .github/workflows/testing.yml | 62 +++++++++++++++++++++++++++ .travis.yml | 25 ----------- Makefile | 6 +-- README.rst | 10 ++--- dev_requirements.txt | 9 ++++ requirements.txt | 5 --- tests/test_IS.py | 2 +- tests/test_base91.py | 2 +- tests/test_exceptions.py | 2 +- tests/test_parse.py | 2 +- tests/test_parse_comment_telemetry.py | 2 +- tests/test_parse_common.py | 2 +- tests/test_parse_misc.py | 2 +- tests/test_parse_weather_data.py | 2 +- tests/test_passcode.py | 2 +- tests/test_util.py | 2 +- 17 files changed, 96 insertions(+), 50 deletions(-) create mode 100644 .coveragerc create mode 100644 .github/workflows/testing.yml delete mode 100644 .travis.yml create mode 100644 dev_requirements.txt delete mode 100644 requirements.txt diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..c25bdcf --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ + +# Docs: https://coverage.readthedocs.org/en/latest/config.html + +[run] +branch = False + +# If True, stores relative file paths in data file (needed for Github Actions). +# Using this parameter requires coverage>=5.0 +relative_files = True diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..5694892 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,62 @@ +name: Tests + +on: + push: + branches: [ master ] + paths-ignore: + - '.gitignore' + - '*.md' + - '*.rst' + - 'LICENSE' + - 'dev_requirements.txt' + pull_request: + branches: [ master ] + paths-ignore: + - '.gitignore' + - '*.md' + - '*.rst' + - 'LICENSE' + - 'dev_requirements.txt' +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + steps: + - uses: actions/checkout@v2 + - name: Set up Python Env + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install dependencies + run: | + make init + - name: Run Tests + run: | + make test + - name: Upload to Coveralls + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_PARALLEL: true + COVERALLS_FLAG_NAME: "${{ matrix.os }}_${{ matrix.python-version }}" + run: | + coveralls --service=github + + coveralls: + name: Finish Coveralls + needs: test + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Install coveralls + run: | + pip3 install --upgrade coveralls + - name: Send coverage finish to coveralls.io + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + coveralls --finish diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c130959..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python -sudo: false -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" - - "nightly" - - "pypy" - - "pypy3" -matrix: - include: - - python: 3.7 - dist: xenial - sudo: true -install: - - make init - - pip install coveralls - - pip install scrutinizer-ocular -script: - - make test -after_success: - - coveralls - - ocular - diff --git a/Makefile b/Makefile index 58a44d7..ef50346 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,11 @@ help: @echo "$$HELPBODY" init: - pip install -r requirements.txt + pip install -r dev_requirements.txt test: - rm -f .coverage aprslib/*.pyc - nosetests --verbosity $(verbosity) --with-coverage --cover-package=aprslib + rm -f .coverage aprslib/*.pyc tests/*.pyc + PYTHONHASHSEED=0 pytest --tb=short --cov-config .coveragerc --cov=aprslib tests pylint: pylint -r n -f colorized aprslib || true diff --git a/README.rst b/README.rst index 185d9cd..6119dbc 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ APRS library for Python ~~~~~~~~~~~~~~~~~~~~~~~ -|pypi| |coverage| |scru| |master_build| |docs| +|pypi| |coverage| |master_build| |docs| A python library for dealing with APRS. It can be used to interact with APRS-IS servers, sending and receiving. @@ -36,12 +36,8 @@ Contribution :target: https://coveralls.io/r/rossengeorgiev/aprs-python?branch=master :alt: Test coverage -.. |scru| image:: https://scrutinizer-ci.com/g/rossengeorgiev/aprs-python/badges/quality-score.png?b=master - :target: https://scrutinizer-ci.com/g/rossengeorgiev/aprs-python/?branch=master - :alt: Scrutinizer score - -.. |master_build| image:: https://img.shields.io/travis/rossengeorgiev/aprs-python/master.svg?style=flat&label=master%20build - :target: http://travis-ci.org/rossengeorgiev/aprs-python +.. |master_build| image:: https://github.com/rossengeorgiev/aprs-python/workflows/Tests/badge.svg?branch=master + :target: https://github.com/rossengeorgiev/aprs-python/actions?query=workflow%3A%22Tests%22+branch%3Amaster :alt: Build status of master branch .. |docs| image:: https://readthedocs.org/projects/aprs-python/badge/?version=latest diff --git a/dev_requirements.txt b/dev_requirements.txt new file mode 100644 index 0000000..48e1f64 --- /dev/null +++ b/dev_requirements.txt @@ -0,0 +1,9 @@ + +mox3 + +coverage>=5.0; python_version == '2.7' or python_version >= '3.5' +pytest-cov>=2.7.0; python_version == '2.7' or python_version >= '3.5' + +# coveralls 2.0 has removed support for Python 2.7 and 3.4 +git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7' +coveralls>=2.1.2; python_version >= '3.5' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 695a581..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -nose -coverage -unittest2 -mox3 -sphinx==1.3.5 diff --git a/tests/test_IS.py b/tests/test_IS.py index 00326c1..36f0d99 100644 --- a/tests/test_IS.py +++ b/tests/test_IS.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest import socket import sys import os diff --git a/tests/test_base91.py b/tests/test_base91.py index f6924ef..ef4b6c1 100644 --- a/tests/test_base91.py +++ b/tests/test_base91.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest import sys from aprslib import base91 diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index f6f06df..68595e4 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest from aprslib.exceptions import * diff --git a/tests/test_parse.py b/tests/test_parse.py index 0a08938..4974f8d 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,7 +1,7 @@ # encoding: utf-8 import sys -import unittest2 as unittest +import unittest from mox3 import mox from aprslib import parse diff --git a/tests/test_parse_comment_telemetry.py b/tests/test_parse_comment_telemetry.py index 59447b4..2240660 100644 --- a/tests/test_parse_comment_telemetry.py +++ b/tests/test_parse_comment_telemetry.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest from aprslib.parsing import parse_comment_telemetry from aprslib import base91 diff --git a/tests/test_parse_common.py b/tests/test_parse_common.py index 64190dc..82b3b90 100644 --- a/tests/test_parse_common.py +++ b/tests/test_parse_common.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest import string from random import randint, randrange, sample from datetime import datetime diff --git a/tests/test_parse_misc.py b/tests/test_parse_misc.py index 65ec1c2..0c69c54 100644 --- a/tests/test_parse_misc.py +++ b/tests/test_parse_misc.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest from aprslib.parsing.misc import parse_status, parse_invalid, parse_user_defined diff --git a/tests/test_parse_weather_data.py b/tests/test_parse_weather_data.py index 5312c34..634ed5f 100644 --- a/tests/test_parse_weather_data.py +++ b/tests/test_parse_weather_data.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest from aprslib.parsing import parse_weather_data from aprslib.parsing import parse diff --git a/tests/test_passcode.py b/tests/test_passcode.py index 03181b0..af51566 100644 --- a/tests/test_passcode.py +++ b/tests/test_passcode.py @@ -1,4 +1,4 @@ -import unittest2 as unittest +import unittest from aprslib import passcode diff --git a/tests/test_util.py b/tests/test_util.py index 7af037d..642aca4 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,5 +1,5 @@ -import unittest2 as unittest +import unittest from aprslib import util From f5776bf2f7c4279e60dc957ac1684bdf5b18c44c Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Wed, 17 Feb 2021 22:19:40 +0000 Subject: [PATCH 6/6] ci: add py3.9 --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 5694892..003f12e 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3] + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy2, pypy3] steps: - uses: actions/checkout@v2 - name: Set up Python Env