aboutsummaryrefslogtreecommitdiff
path: root/tests/test_trace.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-06-20 00:23:45 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-06-20 00:23:45 -0400
commit9e0cffd2a6ff38f84b7c813a9bfad87bde0938d3 (patch)
tree1d68cfb59898beb628e9c6150c7f3e5a5f3f18ef /tests/test_trace.py
parentbe0ba8b3d2c1e52fc0fc8c0de632e4dd6bf2939a (diff)
downloadqolab-9e0cffd2a6ff38f84b7c813a9bfad87bde0938d3.tar.gz
qolab-9e0cffd2a6ff38f84b7c813a9bfad87bde0938d3.zip
added test for Trace saving in raw and compressed formsv0.13
Diffstat (limited to 'tests/test_trace.py')
-rw-r--r--tests/test_trace.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_trace.py b/tests/test_trace.py
index 65a9f5b..e811831 100644
--- a/tests/test_trace.py
+++ b/tests/test_trace.py
@@ -1,6 +1,7 @@
import pytest
from qolab.data.trace import loadTrace
import numpy as np
+import os
def isItExpectedTrace(tr):
cfg = tr.getConfig()
@@ -45,3 +46,45 @@ def test_tryCompressedIfMissing():
with pytest.raises(FileNotFoundError) as exc_info:
tr = loadTrace(fname, tryCompressedIfMissing=False)
+ tr = loadTrace('tests/trace_test_data/xtrace1.dat')
+ assert isItExpectedTrace(tr) == True
+
+def test_saving_raw():
+ import tempfile
+ with tempfile.NamedTemporaryFile(delete=True) as fp:
+ fp.close()
+ fname = fp.name
+ assert not os.path.exists(fname)
+
+ tr = loadTrace('tests/trace_test_data/xtrace1.dat')
+ tr.save(fname, compressionmethod=None)
+ trLoaded = loadTrace(fname)
+ assert isItExpectedTrace(trLoaded)
+ os.remove(fname)
+
+def test_saving_gzip():
+ import tempfile
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
+ fp.close()
+ fname = fp.name + '.gz'
+ assert not os.path.exists(fname)
+
+ tr = loadTrace('tests/trace_test_data/xtrace1.dat')
+ tr.save(fname, compressionmethod='gzip')
+ trLoaded = loadTrace(fname)
+ assert isItExpectedTrace(trLoaded)
+ os.remove(fname)
+
+def test_saving_gzip():
+ import tempfile
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
+ fp.close()
+ fname = fp.name + '.bz'
+ assert not os.path.exists(fname)
+
+ tr = loadTrace('tests/trace_test_data/xtrace1.dat')
+ tr.save(fname, compressionmethod='bzip')
+ trLoaded = loadTrace(fname)
+ assert isItExpectedTrace(trLoaded)
+ os.remove(fname)
+