Skip to content

Commit

Permalink
Updated the test scripts for README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeqfu committed Nov 28, 2019
1 parent 9070032 commit 1bf9df9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# download.py

import Image
from PIL import Image

from pyhelpers.dir import cd
from pyhelpers.download import download
Expand All @@ -9,5 +9,8 @@
path_to_python_logo = cd("tests", "picture", "python-logo.png")
download(url, path_to_python_logo)

path_to_python_logo = "python-logo.png"
download(url, path_to_python_logo)

image = Image.open(path_to_python_logo)
image.show()
2 changes: 1 addition & 1 deletion tests/test_misc.py → tests/test_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# misc.py

from pyhelpers.misc import confirmed
from pyhelpers.ops import confirmed

confirmed(prompt="Continue?...", confirmation_required=True)
13 changes: 10 additions & 3 deletions tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd

from pyhelpers.dir import cd
from pyhelpers.store import load_pickle, save_pickle
from pyhelpers.store import load_feather, load_pickle, save_feather, save_pickle

xy_array = np.array([(530034, 180381), # London
(406689, 286822), # Birmingham
Expand All @@ -13,8 +13,15 @@
dat = pd.DataFrame(xy_array, columns=['Easting', 'Northing'])

path_to_test_pickle = cd("tests", "data", "dat.pickle") # cd("tests\\data\\dat.pickle")
print(path_to_test_pickle)
print(path_to_test_pickle) # >>> C:\Users\fuq\DataShare\Experiments\pyhelpers\tests\data\dat.pickle

save_pickle(dat, path_to_test_pickle)
# Save dat as a pickle file
save_pickle(dat, path_to_test_pickle, verbose=True)
dat_retrieved = load_pickle(path_to_test_pickle)
print(dat_retrieved.equals(dat)) # should return True

# Save dat as a feather file
path_to_test_feather = path_to_test_pickle.replace(".pickle", ".feather")
save_feather(dat, path_to_test_feather, verbose=True)
dat_retrieved = load_feather(path_to_test_feather)
print(dat_retrieved.equals(dat)) # should return True

0 comments on commit 1bf9df9

Please sign in to comment.