I have a Python project with a bunch of tests that have already been implemented, and I would like to start testing them to compare the performance of code, servers, etc. over time. Finding files in a manner similar to Nose was not a problem, because in any case I have a βtestβ in the names of all my test files. However, I am trying to run these tests dynamically.
As of now, I can run a script that takes a directory path as an argument and returns a list of file paths, for example:
def getTestFiles(directory):
fileList = []
print "Searching for 'test' in " + directory
if not os.path.isdir(os.path.dirname(directory)):
raise InputError(directory, "Not a valid directory")
else:
for root, dirs, files in os.walk(directory):
for f in files:
if "test" in f and f.endswith(".py"):
fileList.append(os.path.join(root, f))
return fileList
The problem is that these files may have different syntax, which I am trying to figure out how to handle. For instance:
TestExampleOne:
import dummy1
import dummy2
import dummy3
class TestExampleOne(unittest.TestCase):
@classmethod
def setUpClass(cls):
def test_one(self):
def test_two(self):
def test_three(self):
TestExampleTwo:
import dummy1
import dummy2
import dummy3
def setup(self):
try:
except Exception as e:
logger.exception(e)
def test_one():
def test_two():
def test_three():
TestExampleThree:
import dummy1
import dummy2
import dummy3
def setup(self):
try:
except Exception as e:
logger.exception(e)
class TestExampleTwo(unittest.TestCase):
def test_one(self):
def test_two(self):
class TestExampleThree(unittest.TestCase):
def test_one(self):
def test_two(self):
, , "test" , unit test , . , - NodeVisitor , . , , .