Commit bbfbddbc authored by Stefan Behnel's avatar Stefan Behnel

keep tests from different directories separate to prevent overwriting files with the same name

parent d467013c
...@@ -55,6 +55,12 @@ class TestBuilder(object): ...@@ -55,6 +55,12 @@ class TestBuilder(object):
return suite return suite
def handle_directory(self, path, context): def handle_directory(self, path, context):
workdir = os.path.join(self.workdir, context)
if not os.path.exists(workdir):
os.makedirs(workdir)
if workdir not in sys.path:
sys.path.insert(0, workdir)
expect_errors = (context == 'errors') expect_errors = (context == 'errors')
suite = unittest.TestSuite() suite = unittest.TestSuite()
filenames = os.listdir(path) filenames = os.listdir(path)
...@@ -69,10 +75,10 @@ class TestBuilder(object): ...@@ -69,10 +75,10 @@ class TestBuilder(object):
continue continue
if context in TEST_RUN_DIRS: if context in TEST_RUN_DIRS:
test = CythonRunTestCase( test = CythonRunTestCase(
path, self.workdir, module, self.annotate) path, workdir, module, self.annotate)
else: else:
test = CythonCompileTestCase( test = CythonCompileTestCase(
path, self.workdir, module, expect_errors, self.annotate) path, workdir, module, expect_errors, self.annotate)
suite.addTest(test) suite.addTest(test)
return suite return suite
...@@ -89,7 +95,7 @@ class CythonCompileTestCase(unittest.TestCase): ...@@ -89,7 +95,7 @@ class CythonCompileTestCase(unittest.TestCase):
def shortDescription(self): def shortDescription(self):
return "compiling " + self.module return "compiling " + self.module
def tearDown(self): def _tearDown(self):
if os.path.exists(self.workdir): if os.path.exists(self.workdir):
for rmfile in os.listdir(self.workdir): for rmfile in os.listdir(self.workdir):
if self.annotate and rmfile.endswith(".html"): if self.annotate and rmfile.endswith(".html"):
...@@ -218,9 +224,6 @@ if __name__ == '__main__': ...@@ -218,9 +224,6 @@ if __name__ == '__main__':
shutil.rmtree(WORKDIR, ignore_errors=True) shutil.rmtree(WORKDIR, ignore_errors=True)
os.makedirs(WORKDIR) os.makedirs(WORKDIR)
if not sys.path or sys.path[0] != WORKDIR:
sys.path.insert(0, WORKDIR)
print "Running tests against Cython %s" % version print "Running tests against Cython %s" % version
print "Python", sys.version print "Python", sys.version
print print
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment