Skip to content

Commit

Permalink
tests: fix tsv export tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 3, 2024
1 parent feb94bc commit 09ff860
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions tests/test_rtdc_export_tsv.py
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
import io
from os.path import join
import tempfile

import dclab

from helper_methods import example_data_dict


def test_tsv_export():
def test_tsv_export(tmp_path):
keys = ["area_um", "deform", "time", "frame", "fl3_width"]
ddict = example_data_dict(size=222, keys=keys)
ds = dclab.new_dataset(ddict)

edest = tempfile.mkdtemp()
f1 = join(edest, "test.tsv")
f2 = join(edest, "test_unicode.tsv")
f1 = tmp_path / "test.tsv"
f2 = tmp_path / "test_unicode.tsv"

ds.export.tsv(f1, keys, override=True)
ds.export.tsv(f2, [u"area_um", u"deform", u"time",
u"frame", u"fl3_width"], override=True)

with io.open(f1) as fd:
with f1.open("r") as fd:
a1 = fd.read()

with io.open(f2) as fd:
with f2.open("r") as fd:
a2 = fd.read()

assert a1 == a2
assert len(a1) != 0


def test_tsv_override():
def test_tsv_override(tmp_path):
keys = ["area_um", "deform", "time", "frame", "fl3_width"]
ddict = example_data_dict(size=212, keys=keys)
ds = dclab.new_dataset(ddict)

edest = tempfile.mkdtemp()
f1 = join(edest, "test.tsv")
f1 = tmp_path / "test.tsv"
ds.export.tsv(f1, keys, override=True)
try:
ds.export.tsv(f1[:-4], keys, override=False)
ds.export.tsv(f1.with_name(f1.stem), keys, override=False)
except OSError:
pass
else:
raise ValueError("Should append .tsv and not override!")


def test_tsv_not_filtered():
def test_tsv_not_filtered(tmp_path):
keys = ["area_um", "deform", "time", "frame", "fl3_width"]
ddict = example_data_dict(size=127, keys=keys)
ds = dclab.new_dataset(ddict)

edest = tempfile.mkdtemp()
f1 = join(edest, "test.tsv")
f1 = tmp_path / "test.tsv"
ds.export.tsv(f1, keys, filtered=False)

0 comments on commit 09ff860

Please sign in to comment.