Skip to content

Commit

Permalink
TST: add pickle and txt io tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elcorto committed Nov 5, 2023
1 parent b8ea039 commit 942172e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pandas as pd
import numpy as np
import pytest
import joblib

import psweep as ps

Expand Down Expand Up @@ -885,3 +886,20 @@ def test_run_local_deprecated():
params = ps.plist("a", [1, 2, 3])
with pytest.deprecated_call():
ps.run_local(func_a, params, save=False)


def test_pickle_io():
obj = dict(a=1, b=_Foo(), c=np.sin)
hsh = lambda obj: joblib.hash(obj, hash_name="sha1")
with tempfile.TemporaryDirectory() as tmpdir:
fn = f"{tmpdir}/path/that/has/to/be/created/file.pk"
ps.pickle_write(fn, obj)
assert hsh(obj) == hsh(ps.pickle_read(fn))


def test_file_io():
txt = "some random text"
with tempfile.TemporaryDirectory() as tmpdir:
fn = f"{tmpdir}/path/that/has/to/be/created/file.txt"
ps.file_write(fn, txt)
assert txt == ps.file_read(fn)

0 comments on commit 942172e

Please sign in to comment.