Skip to content

Instantly share code, notes, and snippets.

@patsissons
Created May 19, 2017 18:27
Show Gist options
  • Save patsissons/48b29ff715187a4eb7a5c178ff43142a to your computer and use it in GitHub Desktop.
Save patsissons/48b29ff715187a4eb7a5c178ff43142a to your computer and use it in GitHub Desktop.
TeamCity python test suite loader/runner
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