summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-08-04 13:52:17 -0500
committerBryan Bishop <kanzure@gmail.com>2013-08-04 13:52:17 -0500
commitb401a99d425687801bf8a2f6c53a4baabcb208ab (patch)
tree0a651b4d1f3f070d5ff25d0ff0674aa8106a4b3f /tests
parent3f68f25dbfbe07db7c129cdf08716487006f55fc (diff)
clean up the formatting in test_write_all_labels
Diffstat (limited to 'tests')
-rw-r--r--tests/tests.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/tests.py b/tests/tests.py
index 84dc0a6..7b37794 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -429,9 +429,11 @@ class TestAsmList(unittest.TestCase):
def test_write_all_labels(self):
"""dumping json into a file"""
filename = "test_labels.json"
+
# remove the current file
if os.path.exists(filename):
os.system("rm " + filename)
+
# make up some labels
labels = []
# fake label 1
@@ -440,18 +442,23 @@ class TestAsmList(unittest.TestCase):
# fake label 2
label = {"line_number": 15, "bank": 2, "label": "SomeOtherLabel", "address": 0x9F0A}
labels.append(label)
+
# dump to file
write_all_labels(labels, filename=filename)
+
# open the file and read the contents
file_handler = open(filename, "r")
contents = file_handler.read()
file_handler.close()
+
# parse into json
obj = json.read(contents)
+
# begin testing
self.assertEqual(len(obj), len(labels))
self.assertEqual(len(obj), 2)
self.assertEqual(obj, labels)
+
# remove the current file
if os.path.exists(filename):
os.system("rm " + filename)