How to use the unittest2.defaultTestLoader.discover function in unittest2

To help you get started, we’ve selected a few unittest2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github citrix / citrix-adc-ansible-modules / load_tests.py View on Github external
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)
github artsalliancemedia / smpteparsers / run_tests.py View on Github external
def main():
    logger = logging.getLogger()
    logger.addHandler(NullHandler())

    loader = unittest2.defaultTestLoader.discover(u'.')
    runner = unittest2.runner.TextTestRunner()
    runner.run(loader)
github LMFDB / lmfdb / testing.py View on Github external
# -*- 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 ""
github mongodb-labs / mongo-web-shell / tests / __init__.py View on Github external
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__)
github splunk / splunk-sdk-python / tests / test_all.py View on Github external
# 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)
github pydicom / pydicom / tests / run_tests.py View on Github external
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
github Yelp / mrjob / tests / suite.py View on Github external
def load_tests():
    return unittest.defaultTestLoader.discover(dirname(__file__))
github earwig / mwparserfromhell / discover_tests.py View on Github external
def additional_tests():
    return unittest2.defaultTestLoader.discover(os.path.dirname(__file__))
github alexras / lsmc / tests / run_tests.py View on Github external
#!/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)
github etingof / pysmi / setup.py View on Github external
def run(self):
            suite = unittest.defaultTestLoader.discover('tests')
            unittest.TextTestRunner(verbosity=2).run(suite)