def __init__(self):
pass
def setUp(self):
def tearDown(self):
def setUpFixture(self):
def tearDownFixture(self):
def failUnlessRaises(self, excClass, callableObj, *args, **kwargs):
if issubclass(excClass, System.Exception):
try:
callableObj(*args, **kwargs)
except Exception, e:
if hasattr(e, "clsException") and (type(e.clsException) == excClass):
return
else:
except excClass:
if hasattr(excClass,'__name__'):
excName = excClass.__name__
excName = str(excClass)
raise AssertionException("%s not raised" % excName)
def getTestCaseNames(testCaseClass, prefix):
def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=prefix):
return attrname.startswith(prefix) and callable(getattr(testCaseClass, attrname))
testFnNames = filter(isTestMethod, dir(testCaseClass))
for baseclass in testCaseClass.__bases__:
for testFnName in getTestCaseNames(baseclass, prefix):
if testFnName not in testFnNames:
testFnNames.append(testFnName)
testFnNames.sort(cmp)
return testFnNames
public class MyPythonSuite : AbstractPythonSuite
{
public MyPythonSuite()
: base("MyPythonFixture.py")
}
public class DynamicPythonSuite : AbstractPythonSuite
public DynamicPythonSuite()
: base(FindSuitablePythonScripts())
private static string[] FindSuitablePythonScripts()
List<string> scripts = new List<string>();
Assembly assembly = typeof (DynamicPythonSuite).Assembly;
string indication = "#test";
foreach (string potentialScript in assembly.GetManifestResourceNames())
using (StreamReader reader =
new StreamReader(assembly.GetManifestResourceStream(potentialScript)))
if (reader.ReadLine().Trim().StartsWith(indication,
true, CultureInfo.InvariantCulture))
scripts.Add(potentialScript);
return scripts.ToArray();