Skip to content

Commit

Permalink
Improve JSON test to verify file existence and succesful retrieval.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmwv committed Feb 16, 2016
1 parent af32398 commit 2eeb611
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/testJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from __future__ import print_function

import json
import os
import sys
import tempfile
Expand All @@ -44,6 +45,11 @@ def testSaveJson(self):
ps = pipeBase.Struct(foo=2, bar=[10, 20], hard=np.array([5,10]))
_, tmpFilepath = tempfile.mkstemp(suffix='.json')
saveKpmToJson(ps, tmpFilepath)
self.assertTrue(os.path.exists(tmpFilepath))

readBackData = json.load(open(tmpFilepath))
self.assertEqual(readBackData['foo'], 2)

os.unlink(tmpFilepath)


Expand All @@ -61,7 +67,6 @@ def run(shouldExit=False):
"""Run the tests"""
utilsTests.run(suite(), shouldExit)


if __name__ == "__main__":
if "--display" in sys.argv:
display = True
run(True)

0 comments on commit 2eeb611

Please sign in to comment.