summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2012-04-02 11:45:42 -0500
committerBryan Bishop <kanzure@gmail.com>2012-04-02 11:45:42 -0500
commit1a3aebf191f7e99a497b64bd863928bbf72b88f7 (patch)
tree20270c1d886e21ba849356f2c34b0d57f9e8ad04
parentbd7453f70cb209bd0201d2e0bdcef9d85462dd77 (diff)
make tests pass the first time they are ran
-rw-r--r--extras/crystal.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/extras/crystal.py b/extras/crystal.py
index 32d85ccc4..4be33bed0 100644
--- a/extras/crystal.py
+++ b/extras/crystal.py
@@ -445,6 +445,7 @@ class RomStr(str):
return len(self)
def __repr__(self):
return "RomStr(too long)"
+rom = RomStr(None)
def load_rom(filename="../baserom.gbc"):
"""loads bytes into memory"""
global rom
@@ -452,6 +453,16 @@ def load_rom(filename="../baserom.gbc"):
rom = RomStr(file_handler.read())
file_handler.close()
return rom
+def maybe_load_rom(filename="../baserom.gbc"):
+ """checks that the loaded rom matches the path
+ and then loads the rom if necessary."""
+ global rom
+ if rom != RomStr(None) and rom != None:
+ return rom
+ if not isinstance(rom, RomStr):
+ return load_rom(filename=filename)
+ elif os.lstat(filename).st_size != len(rom):
+ return load_rom(filename)
class AsmList(list):
"""simple wrapper to prevent all asm lines from being shown on screen"""
@@ -6608,6 +6619,7 @@ class TestScript(unittest.TestCase):
class TestByteParams(unittest.TestCase):
@classmethod
def setUpClass(cls):
+ maybe_load_rom()
cls.address = 10
cls.sbp = SingleByteParam(address=cls.address)
@classmethod