[livecoding] r139 committed - - Fixes remaining unit test bugs. One was related to the use of MODE_...

1 view
Skip to first unread message

livec...@googlecode.com

unread,
Feb 12, 2010, 9:44:17 PM2/12/10
to py-livecod...@googlegroups.com
Revision: 139
Author: richard.m.tew
Date: Fri Feb 12 18:43:15 2010
Log: - Fixes remaining unit test bugs. One was related to the use of
MODE_UPDATE as the default. And the other was related to the the script
global deletion fix not suiting MODE_OVERWRITE (which hangs onto them for
the life of objects).
http://code.google.com/p/livecoding/source/detail?r=139

Modified:
/trunk/namespace.py
/trunk/reloader.py
/trunk/tests/test_reloading.py

=======================================
--- /trunk/namespace.py Fri Feb 12 16:33:52 2010
+++ /trunk/namespace.py Fri Feb 12 18:43:15 2010
@@ -21,17 +21,19 @@
lastError = None
contributedAttributes = None

- def __init__(self, filePath, namespacePath, implicitLoad=True):
+ def __init__(self, filePath, namespacePath, implicitLoad=True,
delGlobals=False):
self.filePath = filePath
self.namespacePath = namespacePath

self.scriptGlobals = {}
+ self.delGlobals = delGlobals

if implicitLoad:
self.Load(filePath)

def __del__(self):
- self.scriptGlobals.clear()
+ if self.delGlobals:
+ self.scriptGlobals.clear()
# print "GC", self.namespacePath, self.filePath,
hex(id(self.scriptGlobals))

def __repr__(self):
@@ -160,7 +162,7 @@
unitTest = True
dependencyResolutionPasses = 10

- def __init__(self, baseDirPath=None, baseNamespace=None):
+ def __init__(self, baseDirPath=None, baseNamespace=None,
delScriptGlobals=False):
# Script file objects indexed in different ways.
self.filesByPath = {}
self.filesByDirectory = {}
@@ -169,6 +171,7 @@
self.namespaces = {}

self.classCreationCallback = None
+ self.delScriptGlobals = delScriptGlobals

self.SetBaseDirectory(baseDirPath)
self.SetBaseNamespaceName(baseNamespace)
@@ -340,7 +343,7 @@
def LoadScript(self, filePath, namespacePath):
logger.debug("LoadScript %s", filePath)

- return self.scriptFileClass(filePath, namespacePath)
+ return self.scriptFileClass(filePath, namespacePath,
delGlobals=self.delScriptGlobals)

def RunScript(self, scriptFile, tentative=False):
logger.debug("RunScript %s", scriptFile.filePath)
=======================================
--- /trunk/reloader.py Fri Feb 12 18:20:10 2010
+++ /trunk/reloader.py Fri Feb 12 18:43:15 2010
@@ -79,7 +79,7 @@
# Directory registration support.

def AddDirectory(self, baseNamespace, baseDirPath):
- handler = self.scriptDirectoryClass(baseDirPath, baseNamespace)
+ handler = self.scriptDirectoryClass(baseDirPath, baseNamespace,
delScriptGlobals=(self.mode == MODE_UPDATE))
if self.classCreationCallback:
handler.SetClassCreationCallback(self.classCreationCallback)

=======================================
--- /trunk/tests/test_reloading.py Fri Feb 12 17:07:03 2010
+++ /trunk/tests/test_reloading.py Fri Feb 12 18:43:15 2010
@@ -159,7 +159,7 @@

"""
scriptDirPath = GetScriptDirectory()
- cr = self.codeReloader = reloader.CodeReloader()
+ cr = self.codeReloader =
reloader.CodeReloader(mode=reloader.MODE_OVERWRITE)
cr.scriptDirectoryClass = ReloadableScriptDirectoryNoUnitTesting

scriptDirectory = cr.AddDirectory("game", scriptDirPath)
@@ -336,7 +336,7 @@
versions of a class, still work.
"""
scriptDirPath = GetScriptDirectory()
- cr = self.codeReloader = reloader.CodeReloader()
+ cr = self.codeReloader =
reloader.CodeReloader(mode=reloader.MODE_OVERWRITE)
cr.scriptDirectoryClass = ReloadableScriptDirectoryNoUnitTesting
scriptDirectory = cr.AddDirectory("game", scriptDirPath)
self.failUnless(scriptDirectory is not None, "Script loading
failure")
@@ -1109,6 +1109,6 @@
return os.path.join(os.path.dirname(parentDirPath), "scripts")

if __name__ == "__main__":
- logging.basicConfig(level=logging.DEBUG)
+ logging.basicConfig(level=logging.WARNING)

unittest.main()

Reply all
Reply to author
Forward
0 new messages