mirror of https://github.com/gnuradio/SigMF
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 reportpull/57/head
parent
bf4b4ffa40
commit
b562b6bb69
@ -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
|
Loading…
Reference in new issue