Skip to content

Commit 5ce4da0

Browse files
committed
Use parse_path(), use absolute path for memo file removal
No need to do the path-splitting and -reassmbling manually, that's exactly what parse_path() is there for.
1 parent d61b1a0 commit 5ce4da0

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

  • tests/imagej/bioformats/write_bf_memoryfile

tests/imagej/bioformats/write_bf_memoryfile/test_01.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22

33

44
import os
5+
from imcflibs.pathtools import parse_path
56
from imcflibs.imagej import bioformats
67

78

8-
parent_dir = str(PYTHON_IMCFLIBS_TESTDATA).replace("\\", "/")
9-
filename = "10x_phmax.czi"
10-
full_path = parent_dir + "/" + "10x_phmax.czi"
11-
bfmemofilename = "." + filename + ".bfmemo"
12-
os.chdir(parent_dir) # DANGEROUS, relative paths and calling remove() below!
13-
if os.path.isfile(bfmemofilename):
14-
print("bf memo file already existed and was removed")
15-
os.remove(bfmemofilename)
9+
components = parse_path("systems/lsm700/beads/10x_phmax.czi", PYTHON_IMCFLIBS_TESTDATA)
10+
full_path = components["full"]
11+
bfmemofile = components["path"] + "." + components["fname"] + ".bfmemo"
12+
13+
if os.path.isfile(bfmemofile):
14+
print("BF memory file [%s] already exists, removing..." % bfmemofile)
15+
os.remove(bfmemofile)
16+
1617

1718
bioformats.write_bf_memoryfile(full_path)
1819

19-
if not os.path.isfile(bfmemofilename):
20-
print("Test FAILED. A bf memo file does not exist.")
20+
21+
if not os.path.isfile(bfmemofile):
22+
print("Test FAILED: can't find BF memory file [%s]" % bfmemofile)
2123
else:
22-
print("Test passed. A bf memo file was created.")
24+
print("Test passed, BF memory file [%s] was created." % bfmemofile)

0 commit comments

Comments
 (0)