Created
May 19, 2017 18:27
-
-
Save patsissons/48b29ff715187a4eb7a5c178ff43142a to your computer and use it in GitHub Desktop.
TeamCity python test suite loader/runner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from teamcity import is_running_under_teamcity | |
from teamcity.unittestpy import TeamcityTestRunner | |
import os | |
import unittest | |
# update these variables to configure how the test runner loads the test suite | |
testsPath = './tests' | |
testsPattern = '*_test.py' | |
def loadSuite(): | |
return unittest.TestLoader().discover(testsPath, testsPattern) | |
def createRunner(): | |
if is_running_under_teamcity(): | |
print("TeamCity Environment Detected") | |
return TeamcityTestRunner() | |
else: | |
return unittest.TextTestRunner() | |
# run the suite | |
createRunner().run(loadSuite()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment