Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import sys
import unittest2 as unittest
suite = unittest.defaultTestLoader.discover('test')
results = unittest.TextTestRunner(verbosity=2).run(suite)
if results.wasSuccessful():
sys.exit(0)
else:
sys.exit(1)
def main():
logger = logging.getLogger()
logger.addHandler(NullHandler())
loader = unittest2.defaultTestLoader.discover(u'.')
runner = unittest2.runner.TextTestRunner()
runner.run(loader)
# -*- coding: utf8 -*-
# this is the master test file, collecting and running all
# test suits
import os
try:
import unittest2
ts = unittest2.defaultTestLoader.discover(".", pattern="test_*.py")
runner = unittest2.runner.TextTestRunner()
runner.run(ts)
except:
raise
print "You need to have unittest2 installed (backport of 2.7 features to Python 2.6)"
print "most likely run:"
print "$ sage -sh"
print "easy_install -U unittest2"
print ""
def load_tests():
"""Returns the test modules for the mongows package.
The expected output of this function is defined by the unittest module's
load_tests protocol. unittest.main() will runs tests on the modules
returned by this function.
"""
return defaultTestLoader.discover(__name__)
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Runs all the Splunk SDK for Python unit tests."""
from __future__ import absolute_import
import os
try:
import unittest2 as unittest # We must be sure to get unittest2--not unittest--on Python 2.6
except ImportError:
import unittest
os.chdir(os.path.dirname(os.path.abspath(__file__)))
suite = unittest.defaultTestLoader.discover('.')
if __name__ == '__main__':
unittest.TextTestRunner().run(suite)
def loadTestsFromNames(self, *args):
suite = unittest.TestSuite()
try:
suite.addTests(unittest.defaultTestLoader.discover(test_dir))
except AttributeError:
try:
import unittest2
except ImportError:
print("Unittest2 is needed for test discovery with python 2.6")
raise
else:
suite.addTests(unittest2.defaultTestLoader.discover(test_dir))
return suite
def load_tests():
return unittest.defaultTestLoader.discover(dirname(__file__))
def additional_tests():
return unittest2.defaultTestLoader.discover(os.path.dirname(__file__))
#!/usr/bin/env python
import os
import unittest2
import warnings
with warnings.catch_warnings():
warnings.simplefilter("ignore")
suite = unittest2.defaultTestLoader.discover(
os.path.dirname(__file__))
unittest2.TextTestRunner().run(suite)
def run(self):
suite = unittest.defaultTestLoader.discover('tests')
unittest.TextTestRunner(verbosity=2).run(suite)