added py.test support for versions >= 1.0

fixed location for unittests
This commit is contained in:
Ekaterina Tuzova
2010-11-08 13:49:29 +03:00
parent a508e05815
commit a67392af46
4 changed files with 40 additions and 18 deletions
+2 -2
View File
@@ -119,7 +119,7 @@ class FunctionTestCase(TestBase):
return func.__module__
else:
#TODO[kate]: get module of function in jython < 2.2
return "Unknown module"
return "Unknown module."
def _descriptors(self):
"""In most cases, this is the function itself and no arguments. For
@@ -161,7 +161,7 @@ class MethodTestCase(TestBase):
return "%s.%s" % (func.__module__, self.cls.__name__)
else:
#TODO[kate]: get module of function in jython < 2.2
return "Unknown module"
return "Unknown module."
def __str__(self):
func, arg = self._descriptors()
+6 -6
View File
@@ -26,10 +26,6 @@ class TeamcityTestResult(TestResult):
if test._testMethodName == "runTest":
return str(test)
return test._testMethodName
elif hasattr(test, '__testMethodName'):
if test.__testMethodName == "runTest":
return str(test)
return test.__testMethodName
else:
return str(test)
@@ -66,8 +62,12 @@ class TeamcityTestResult(TestResult):
self.current_suite = suite
self.messages.testSuiteStarted(strclass(self.current_suite), location="python_uttestid://" + strclass(self.current_suite))
setattr(test, "startTime", datetime.datetime.now())
self.messages.testStarted(self.getTestName(test), location="python_uttestid://" + str(test.id()))
if hasattr(test, "test"):
id = test.id()[:test.id().find("..") + 1] + test.test.__name__
else:
id = test.id()
self.messages.testStarted(self.getTestName(test), location="python_uttestid://" + str(id))
def stopTest(self, test):
start = getattr(test, "startTime", datetime.datetime.now())
d = datetime.datetime.now() - start
+28 -10
View File
@@ -7,21 +7,39 @@ def fspath_to_url(fspath):
return "file:///" + str(fspath).replace("\\", "/")
def pytest_collectstart(collector):
messages.testSuiteStarted(collector.name, location=fspath_to_url(collector.fspath))
if collector.name != "()":
messages.testSuiteStarted(collector.name, location=fspath_to_url(collector.fspath))
def pytest_runtest_makereport(item, call):
if call.when == "setup":
fspath, lineno, msg = item.reportinfo()
url = fspath_to_url(fspath)
if lineno: url += ":" + str(lineno)
messages.testStarted(item.name, location=url)
# messages.testStarted(item.name, location=url)
def pytest_runtest_logreport(rep):
if rep.failed:
messages.testFailed(rep.item.name, details=rep.longrepr)
elif rep.skipped:
messages.testIgnored(rep.item.name)
messages.testFinished(rep.item.name)
def pytest_runtest_logreport(report):
if report.item._args:
name = report.item.function.__name__ + str(report.item._args)
else:
name = report.item.name
if report.failed:
messages.testFailed(name, details=report.longrepr)
elif report.skipped:
messages.testIgnored(name)
messages.testFinished(name)
def pytest_collectreport(rep):
messages.testSuiteFinished(rep.collector.name)
def pytest_collectreport(report):
if report.collector.name != "()":
messages.testSuiteFinished(report.collector.name)
def pytest_itemstart(item, node=None):
print item.__dict__
if item._args:
name = item.function.__name__ + str(item._args)
else:
name = item.name
if hasattr(item, "_fslineno"):
path = fspath_to_url(item._fslineno[0]) + ":" + str(item._fslineno[1] + 1)
else:
path = fspath_to_url(item.fspath)
messages.testStarted(name, location=path)
@@ -100,6 +100,10 @@ public class PyTestRunConfiguration extends AbstractPythonRunConfiguration {
if (runner.exists()) return runner.getPath();
runner = new File(new File(bin_dir.getParentFile(), "scripts"), PY_TEST);
if (runner.exists()) return runner.getPath();
runner = new File(new File(bin_dir.getParentFile(), "local"), PY_TEST);
if (runner.exists()) return runner.getPath();
runner = new File(new File (new File(bin_dir.getParentFile(), "local"), "bin"), PY_TEST);
if (runner.exists()) return runner.getPath();
return null;
}
}