Skip to content

Commit

Permalink
tests: cleanup afterwards
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 6, 2018
1 parent 7d96613 commit 4abcf0d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
9 changes: 5 additions & 4 deletions nanite/read/read_jpk_meta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Methods to open JPK data files and to obtain meta data.
"""
"""Methods to open JPK data files and to obtain meta data"""
import functools
import pathlib
import shutil
import tempfile
import zipfile

Expand All @@ -14,8 +14,7 @@ class ReadJPKMetaKeyError(BaseException):


def extract_jpk(path_jpk, props_only=False):
""" Extract the JPK data files and return the extracted path.
"""
"""Extract the JPK data files and return the extracted path"""
tdir = tempfile.mkdtemp(prefix="nanite_jpk_")
with zipfile.ZipFile(str(path_jpk)) as fd:
if props_only:
Expand Down Expand Up @@ -123,6 +122,8 @@ def get_meta_data(jpk_file):
# join curve types
md["curve type"] = "-".join(md["curve type"])
md["file"] = jpk_file
# cleanup
shutil.rmtree(tdir, ignore_errors=True)
return md


Expand Down
4 changes: 2 additions & 2 deletions tests/test_dataset.py → tests/test_group.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Test of data set functionalities"""
"""Test group functionalities"""
import pathlib

from nanite import Indentation, IndentationGroup
Expand All @@ -8,7 +8,7 @@
jpkfile = datadir / "spot3-0192.jpk-force"


def test_afm_data_set():
def test_base():
ds1 = IndentationGroup(jpkfile)
ds2 = IndentationGroup(jpkfile)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_jproperties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test of basic opening functionalities"""
import pathlib
import shutil

from nanite.read import read_jpk_meta

Expand All @@ -13,6 +14,7 @@ def test_meta_simple():
tdir = read_jpk_meta.extract_jpk(jpkfilemap)
hpfile = tdir / "index/0/segments/0/segment-header.properties"
read_jpk_meta.get_seg_head_prop(hpfile)
shutil.rmtree(tdir, ignore_errors=True)


def test_mata_single():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_open_jpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_open_jpk_simple():
key = ch.stem
chan_data[key] = read_jpk.load_dat_raw(ch)
assert chan_data["height"][0] == 50.425720226584403
shutil.rmtree(str(tdir))
shutil.rmtree(tdir, ignore_errors=True)


def test_open_jpk_callibration():
Expand Down Expand Up @@ -47,7 +47,7 @@ def test_open_jpk_conversion():
assert chan_data["vDeflection"][0][0] == -5.145579192349918e-10
assert chan_data["height"][0][0] == 2.8783223430683289e-05
assert chan_data["strainGaugeHeight"][0][0] == 2.2815672438768612e-05
shutil.rmtree(str(tdir))
shutil.rmtree(tdir, ignore_errors=True)


def test_get_single_curves():
Expand Down
4 changes: 1 addition & 3 deletions tests/test_open_jpk_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

import numpy as np

from nanite.read import read_jpk, read_jpk_meta
from nanite.read import read_jpk

datadir = pathlib.Path(__file__).resolve().parent / "data"


def test_open_jpk_map():
jpkfile = datadir / "map0d_extracted.jpk-force-map"
read_jpk_meta.get_meta_data(jpkfile)
data = read_jpk.load_jpk(jpkfile)
force = data[0][0][0]["force"]
height = data[0][0][0]["height (measured)"]
Expand All @@ -21,7 +20,6 @@ def test_open_jpk_map():

def test_open_jpk_map2():
jpkfile = datadir / "map2x2_extracted.jpk-force-map"
read_jpk_meta.get_meta_data(jpkfile)
data = read_jpk.load_jpk(jpkfile)
force = data[2][0][0]["force"]
height = data[2][0][0]["height (measured)"]
Expand Down

0 comments on commit 4abcf0d

Please sign in to comment.