-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feb94bc
commit 09ff860
Showing
1 changed file
with
10 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |