This commit is contained in:
s 2021-03-09 20:49:11 +01:00
commit cded128bca
19 changed files with 114 additions and 65 deletions

9
.coveragerc Normal file
View File

@ -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

62
.github/workflows/testing.yml vendored Normal file
View File

@ -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, 3.9, 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

View File

@ -1,26 +0,0 @@
language: python
sudo: false
python:
- "2.7"
- "3.3"
- "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

View File

@ -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

View File

@ -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

View File

@ -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']

View File

@ -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
@ -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):

9
dev_requirements.txt Normal file
View File

@ -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'

View File

@ -1,5 +0,0 @@
nose
coverage
unittest2
mox3
sphinx==1.3.5

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
import socket
import sys
import os
@ -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)

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
import sys
from aprslib import base91

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
from aprslib.exceptions import *

View File

@ -1,7 +1,7 @@
# encoding: utf-8
import sys
import unittest2 as unittest
import unittest
from mox3 import mox
from aprslib import parse

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
from aprslib.parsing import parse_comment_telemetry
from aprslib import base91
@ -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)

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
import string
from random import randint, randrange, sample
from datetime import datetime

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
from aprslib.parsing.misc import parse_status, parse_invalid, parse_user_defined

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
from aprslib.parsing import parse_weather_data
from aprslib.parsing import parse

View File

@ -1,4 +1,4 @@
import unittest2 as unittest
import unittest
from aprslib import passcode

View File

@ -1,5 +1,5 @@
import unittest2 as unittest
import unittest
from aprslib import util