aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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)
+