Browse Source

Add a more robust testing framework

Try:
  `pytest` in the repo root
  `python setup.py test` in the repo root runs pytest
  `tox` in the repo root runs pytest in a virtualenv against all
        intalled interpreters
  `tox -e coverage` in the repo root produces a test coverage report
pull/57/head
Douglas Anderson 4 years ago
parent
commit
b562b6bb69
  1. 3
      setup.cfg
  2. 6
      setup.py
  3. 0
      tests/__init__.py
  4. 45
      tests/conftest.py
  5. 17
      tox.ini

3
setup.cfg

@ -1,2 +1,5 @@
[aliases]
test=pytest
[wheel]
universal = 1

6
setup.py

@ -27,8 +27,12 @@ setup(
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
packages=['sigmf'],
install_requires=['six', 'numpy'],
setup_requires=['pytest-runner'],
tests_require=['pytest>3'],
zip_safe=False
)

0
tests/__init__.py

45
tests/conftest.py

@ -0,0 +1,45 @@
# Copyright 2017 GNU Radio Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import tempfile
import pytest
from sigmf.sigmffile import SigMFFile
from .testdata import TEST_FLOAT32_DATA, TEST_METADATA
@pytest.yield_fixture
def test_data_file():
with tempfile.NamedTemporaryFile() as t:
TEST_FLOAT32_DATA.tofile(t.name)
yield t
@pytest.fixture
def test_sigmffile(test_data_file):
f = SigMFFile()
f.set_global_field("core:datatype", "f32")
f.add_annotation(start_index=0, length=len(TEST_FLOAT32_DATA))
f.add_capture(start_index=0)
f.set_data_file(test_data_file.name)
assert f._metadata == TEST_METADATA
return f

17
tox.ini

@ -0,0 +1,17 @@
[tox]
skip_missing_interpreters = True
envlist = py27, py34, py35, py36, py37
[testenv]
usedevelop = True
deps =
pytest
flake8
commands =
pytest
- flake8
[testenv:coverage]
deps =
pytest-cov
commands = py.test --cov-report term-missing --cov=sigmf tests
Loading…
Cancel
Save