Skip to content

Commit

Permalink
add tests for zip.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kmayerb committed May 31, 2020
1 parent 9c33634 commit 4964fbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
25 changes: 21 additions & 4 deletions zipdist/tests/test_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,10 @@ class Y(Zipdist):
def __init__(self, name):
self.name = name


y = Y(name = 'Simpsons')

y.bart = np.zeros(10)
y.lisa = pd.DataFrame([{"Pi":3.1415,"e":2.7182}])
y._save(dest="Simpsons", dest_tar = "Simpsons.tar.gz")

y2 = Y('Simpsons')
with pytest.raises(AttributeError):
y2.lisa
Expand All @@ -146,7 +143,7 @@ def __init__(self, name):
y2._reload_complex(k ='lisa')
assert isinstance(y2.lisa, pd.DataFrame)

def test_Zipdist_reload_complex():
def test_Zipdist_relad_simple():
""" Example Where only one attribute is loaded using _ready, _reload_complex"""
class Y(Zipdist):
def __init__(self, name):
Expand All @@ -165,6 +162,7 @@ def __init__(self, name):
y2._reload_simple(k = "homer")
assert y2.homer == 1


def test_Zipdist_reload_complex_KeyError():
""" Example Where only one attribute is loaded using _ready, _reload_complex"""
class Y(Zipdist):
Expand All @@ -177,6 +175,25 @@ def __init__(self, name):
y.lisa = pd.DataFrame([{"Pi":3.1415,"e":2.7182}])
y._save(dest="Simpsons", dest_tar = "Simpsons.tar.gz")

y2 = Y('Simpsons')
with pytest.raises(AttributeError):
y2.lisa
y2._ready()
with pytest.raises(KeyError):
y2._reload_complex(k = "moe")

def test_Zipdist_reload_simple_KeyError():
""" Example Where only one attribute is loaded using _ready, _reload_complex"""
class Y(Zipdist):
def __init__(self, name):
self.name = name

y = Y(name = 'Simpsons')
y.homer = 1
y.bart = np.zeros(10)
y.lisa = pd.DataFrame([{"Pi":3.1415,"e":2.7182}])
y._save(dest="Simpsons", dest_tar = "Simpsons.tar.gz")

y2 = Y('Simpsons')
with pytest.raises(AttributeError):
y2.lisa
Expand Down
18 changes: 0 additions & 18 deletions zipdist/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import sys
import warnings


class Zipdist():
"""
A parent class that bestows the ability to rebuild child classes from a .tar.gz file.
Expand Down Expand Up @@ -381,20 +380,3 @@ def _get_simple_attribute_definitions(self, dest = None, dest_tar = None, verbos
# loads the
simple_attributes = json.load(fp)
self._simple_attributes = simple_attributes

















0 comments on commit 4964fbd

Please sign in to comment.