# test tools for the pyxpcom bindings
import unittest
# export a "getmemusage()" function that returns a useful "bytes used" count
# for the current process. Growth in this when doing the same thing over and
# over implies a leak.
try:
import win32api
import win32pdh
import win32pdhutil
except ImportError:
# XXX - win32pdh is slow, particularly finding our current process.
# A better way would be good.
# Our win32pdh specific functions - they can be at the top-level on all
# platforms, but will only actually be called if the modules are available.
def FindMyCounter():
object = "Process"
# We use 2 counters - "ID Process" and "Working Set"
counter = "ID Process"
# Not mine - close the query and try again
else:
raise RuntimeError, "Can't find myself!?"
return val
g_pdh_data = None
# The pdh function that does the work
def pdh_getmemusage():
global g_pdh_data
if g_pdh_data is None:
# The public bit
if have_pdh:
else:
def getmemusage():
return 0
# Test runner utilities, including some support for builtin leak tests.
"""Return a suite of all tests cases contained in testCaseClass"""
leak_tests = []
return test
else:
return ret
pass # hmmm? print "Don't wrap suites yet!", test._tests
else:
print "XXX - what is", test
return test
# A base class our tests should derive from (well, one day it will be)
return suite
try:
finally: