diff --git a/.pylintrc b/.pylintrc index a532961..8fe5f6e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,2 +1,2 @@ [MESSAGES CONTROL] -disable=invalid-name, missing-docstring, too-many-instance-attributes, too-few-public-methods, logging-format-interpolation, consider-using-with +disable=invalid-name, missing-docstring, too-many-instance-attributes, too-few-public-methods, logging-format-interpolation, consider-using-with, redefined-outer-name diff --git a/amodem/tests/__init__.py b/amodem/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/amodem/tests/test_alsa.py b/amodem/tests/test_alsa.py index 76a6527..08d7243 100644 --- a/amodem/tests/test_alsa.py +++ b/amodem/tests/test_alsa.py @@ -1,7 +1,7 @@ -from amodem import alsa, config - import mock +from .. import alsa, config + def test_alsa(): interface = alsa.Interface(config=config.fastest()) diff --git a/amodem/tests/test_async_reader.py b/amodem/tests/test_async_reader.py index fb33398..bb2e856 100644 --- a/amodem/tests/test_async_reader.py +++ b/amodem/tests/test_async_reader.py @@ -1,8 +1,11 @@ -import mock +import logging import time + +import mock import pytest -from amodem import async_reader -import logging + +from .. import async_reader + logging.basicConfig(format='%(message)s') diff --git a/amodem/tests/test_audio.py b/amodem/tests/test_audio.py index cad185d..cd59bfe 100644 --- a/amodem/tests/test_audio.py +++ b/amodem/tests/test_audio.py @@ -1,8 +1,8 @@ -from amodem import audio, config - import mock import pytest +from .. import audio, config + def test(): length = 1024 @@ -31,4 +31,4 @@ def test(): s.close() with pytest.raises(Exception): - interface._error_check(1) + interface._error_check(1) # pylint: disable=protected-access diff --git a/amodem/tests/test_calib.py b/amodem/tests/test_calib.py index 8da5b4e..2b75622 100644 --- a/amodem/tests/test_calib.py +++ b/amodem/tests/test_calib.py @@ -1,13 +1,12 @@ -from amodem import calib -from amodem import common -from amodem import config - from io import BytesIO +import random +import mock import numpy as np -import random import pytest -import mock + +from .. import calib, common, config + config = config.fastest() diff --git a/amodem/tests/test_common.py b/amodem/tests/test_common.py index 34745e2..cd55091 100644 --- a/amodem/tests/test_common.py +++ b/amodem/tests/test_common.py @@ -1,7 +1,7 @@ -from amodem import common -from amodem import config import numpy as np +from .. import common, config + def iterlist(x, *args, **kwargs): x = np.array(x) diff --git a/amodem/tests/test_configs.py b/amodem/tests/test_configs.py index c7d6eb4..db0356b 100644 --- a/amodem/tests/test_configs.py +++ b/amodem/tests/test_configs.py @@ -1,4 +1,4 @@ -from amodem import config +from .. import config def test_bitrates(): diff --git a/amodem/tests/test_detect.py b/amodem/tests/test_detect.py index a0c96a4..9612f40 100644 --- a/amodem/tests/test_detect.py +++ b/amodem/tests/test_detect.py @@ -1,13 +1,8 @@ import numpy as np import pytest -from amodem import dsp -from amodem import recv -from amodem import detect -from amodem import equalizer -from amodem import sampling -from amodem import config -from amodem import common +from .. import common, config, detect, dsp, equalizer, recv, sampling + config = config.fastest() @@ -17,7 +12,7 @@ def test_detect(): x = np.cos(2 * np.pi * config.Fc * t) detector = detect.Detector(config, pylab=common.Dummy()) - samples, amp, freq_err = detector.run(x) + _samples, amp, freq_err = detector.run(x) assert abs(1 - amp) < 1e-12 assert abs(freq_err) < 1e-12 @@ -39,11 +34,11 @@ def symbols_stream(signal): sampler = sampling.Sampler(signal) return dsp.Demux(sampler=sampler, omegas=[omega], Nsym=config.Nsym) r = recv.Receiver(config, pylab=common.Dummy()) - r._prefix(symbols_stream(signal)) + r._prefix(symbols_stream(signal)) # pylint: disable=protected-access with pytest.raises(ValueError): silence = 0 * signal - r._prefix(symbols_stream(silence)) + r._prefix(symbols_stream(silence)) # pylint: disable=protected-access def test_find_start(): diff --git a/amodem/tests/test_dsp.py b/amodem/tests/test_dsp.py index 9a16e58..a46a0a0 100644 --- a/amodem/tests/test_dsp.py +++ b/amodem/tests/test_dsp.py @@ -1,12 +1,11 @@ -from amodem import dsp -from amodem import sampling -from amodem import config -import utils - -import numpy as np import random import itertools +import numpy as np + +from .. import dsp, sampling, config +from . import utils + config = config.fastest() @@ -69,7 +68,7 @@ def quantize(q, s): def test_overflow(): q = dsp.MODEM(config.symbols) r = np.random.RandomState(seed=0) - for i in range(10000): + for _ in range(10000): s = 10*(r.normal() + 1j * r.normal()) quantize(q, s) diff --git a/amodem/tests/test_equalizer.py b/amodem/tests/test_equalizer.py index b95c6f9..7d7e6ca 100644 --- a/amodem/tests/test_equalizer.py +++ b/amodem/tests/test_equalizer.py @@ -1,10 +1,9 @@ from numpy.random import RandomState import numpy as np -import utils -from amodem import equalizer -from amodem import dsp -from amodem import config +from . import utils +from .. import config, dsp, equalizer + config = config.fastest() diff --git a/amodem/tests/test_framing.py b/amodem/tests/test_framing.py index 1465d05..5849d19 100644 --- a/amodem/tests/test_framing.py +++ b/amodem/tests/test_framing.py @@ -1,9 +1,10 @@ -from amodem import framing -import random import itertools +import random import pytest +from .. import framing + def concat(iterable): return bytearray(itertools.chain.from_iterable(iterable)) diff --git a/amodem/tests/test_sampling.py b/amodem/tests/test_sampling.py index cc8ef23..e104dd7 100644 --- a/amodem/tests/test_sampling.py +++ b/amodem/tests/test_sampling.py @@ -1,8 +1,8 @@ -from amodem import sampling -from amodem import common +from io import BytesIO import numpy as np -from io import BytesIO + +from .. import common, sampling def test_resample(): diff --git a/amodem/tests/test_stream.py b/amodem/tests/test_stream.py index 9f8de83..436984a 100644 --- a/amodem/tests/test_stream.py +++ b/amodem/tests/test_stream.py @@ -1,7 +1,8 @@ -from amodem import stream import subprocess as sp import sys +from .. import stream + script = br""" import sys import time diff --git a/amodem/tests/test_transfer.py b/amodem/tests/test_transfer.py index 19d0647..b1e7be1 100644 --- a/amodem/tests/test_transfer.py +++ b/amodem/tests/test_transfer.py @@ -1,15 +1,13 @@ -from amodem import main -from amodem import common -from amodem import sampling -from amodem import config -import utils - -import numpy as np -import os from io import BytesIO +import logging +import os +import numpy as np import pytest -import logging + +from .. import common, config, main, sampling +from . import utils + logging.basicConfig(level=logging.DEBUG, # useful for debugging format='%(asctime)s %(levelname)-12s %(message)s') diff --git a/setup.py b/setup.py index e5c8be9..d54c585 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from setuptools import setup +from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand class PyTest(TestCommand): @@ -21,7 +21,7 @@ def run_tests(self): author_email='dev@romanzey.de', license='MIT', url='http://github.com/romanz/amodem', - packages=['amodem'], + packages=find_packages(), tests_require=['pytest'], cmdclass={'test': PyTest}, install_requires=['numpy'],