예제 #1
0
    def run(self):
        try:
            if sys.version_info < (2, 5):
                print("Tests cannot be run on Python 2.4 or earlier")
                exit(-1)
            elif sys.version_info < (2, 7):
                from unittest2 import TextTestRunner, defaultTestLoader
            else:
                from unittest import TextTestRunner, defaultTestLoader

        except ImportError:
            print("Please install Unittest2 to run the test suite")
            exit(-1)

        from tests import test_aspell_python
        suite = defaultTestLoader.loadTestsFromModule(test_aspell_python)
        if sys.version_info < (3,):
            from tests import test_aspell_for_python_2
            suite.addTests(
                defaultTestLoader.loadTestsFromModule(
                    test_aspell_for_python_2))
        else:
            from tests import test_aspell_for_python_3
            suite.addTests(
                defaultTestLoader.loadTestsFromModule(
                    test_aspell_for_python_3))

        runner = TextTestRunner()
        result = runner.run(suite)
        if result.wasSuccessful() is not True:
            raise SystemExit(int(bool(result.errors or result.failures)))
예제 #2
0
파일: ctest_run.py 프로젝트: Ensembles/ert
def runTestCase(tests, verbosity=0):
    test_result = TextTestRunner(verbosity=verbosity).run(tests)

    if len(test_result.errors) or len(test_result.failures):
        test_result.printErrors()
        return False
    else:
        return True
예제 #3
0
 def run(self):
     """@todo: Docstring for run
     :returns: @todo
     """
 
     loader = TestLoader()
     t = TextTestRunner()
     t.run(loader.loadTestsFromModule(vimdown.tests))
def runTestCase(tests, verbosity=0):
    test_result = TextTestRunner(verbosity=verbosity).run(tests)

    if len(test_result.errors) or len(test_result.failures):
        test_result.printErrors()
        return False
    else:
        return True
예제 #5
0
    def test_doc(self):
        suite = TestSuite()

        for filename in os.listdir('../'):
            if filename.endswith(".py"):
                suite.addTest(doctest.DocFileSuite('../' + filename))

        runner = TextTestRunner(verbosity=2)
        runner.run(suite)
예제 #6
0
    def test_doc(self):
        suite = TestSuite()

        for filename in os.listdir('../'):
            if filename.endswith(".py"):
                suite.addTest(doctest.DocFileSuite('../' + filename))

        runner = TextTestRunner(verbosity=2)
        runner.run(suite)
예제 #7
0
def main():
    loader = unittest2.TestLoader()
    suite = unittest2.TestSuite((
        loader.loadTestsFromTestCase(TestAdaProp),
        loader.loadTestsFromTestCase(TestAdaLog),
        loader.loadTestsFromTestCase(TestAdaSched),
        loader.loadTestsFromTestCase(TestAdaClient),
        loader.loadTestsFromTestCase(TestAdaOta),
    ))

    runner = TextTestRunner(verbosity=2)
    runner.run(suite)
예제 #8
0
def main():
    # flake8
    flake8 = get_style_guide(exclude=['.tox', 'build'])
    report = flake8.check_files([BASE_DIR])

    exit_code = print_report(report, flake8)
    if exit_code > 0:
        return exit_code

    # unit tests
    suite = TestLoader().discover(CODE_DIR, top_level_dir=BASE_DIR)
    result = TextTestRunner().run(suite)
    if result.wasSuccessful():
        return 0
    else:
        return 1
예제 #9
0
def main():
    # flake8
    flake8 = get_style_guide(exclude=['.tox', 'build'])
    report = flake8.check_files([BASE_DIR])

    exit_code = print_report(report, flake8)
    if exit_code > 0:
        return exit_code

    # unit tests
    suite = TestLoader().discover(CODE_DIR, top_level_dir=BASE_DIR)
    result = TextTestRunner().run(suite)
    if result.wasSuccessful():
        return 0
    else:
        return 1
예제 #10
0
파일: setup.py 프로젝트: demiurg/Shapely
    def run(self):
        if sys.version_info[0:2] <= (2, 6):
            from unittest2 import TextTestRunner, TestLoader
        else:
            from unittest import TextTestRunner, TestLoader

        try:
            import shapely.tests
        except ImportError:
            self.run_command('build_ext')
            import shapely.tests

        tests = TestLoader().loadTestsFromName('test_suite', shapely.tests)
        runner = TextTestRunner(verbosity=2)
        result = runner.run(tests)

        if result.wasSuccessful():
            sys.exit(0)
        else:
            sys.exit(1)
예제 #11
0
파일: setup.py 프로젝트: Bmcalpine/Shapely
    def run(self):
        # Force an in-place build for testing speedups
        cmd = self.reinitialize_command('build_ext')
        setattr(cmd, 'inplace', 1)
        self.run_command('build_ext')

        if sys.version_info[0:2] <= (2, 6):
            try:
                from unittest2 import TextTestRunner, TestLoader
            except ImportError:
                raise ImportError(
                    "unittest2 is required to run tests with python-%d.%d" %
                    sys.version_info[0:2])
        else:
            from unittest import TextTestRunner, TestLoader

        import shapely.tests
        tests = TestLoader().loadTestsFromName('test_suite', shapely.tests)
        runner = TextTestRunner(verbosity=2)
        result = runner.run(tests)

        if not result.wasSuccessful():
            sys.exit(1)
예제 #12
0
파일: setup.py 프로젝트: blackmad/Shapely
    def run(self):
        # Force an in-place build for testing speedups
        cmd = self.reinitialize_command('build_ext')
        setattr(cmd, 'inplace', 1)
        self.run_command('build_ext')

        if sys.version_info[0:2] <= (2, 6):
            try:
                from unittest2 import TextTestRunner, TestLoader
            except ImportError:
                raise ImportError(
                    "unittest2 is required to run tests with python-%d.%d" %
                    sys.version_info[0:2])
        else:
            from unittest import TextTestRunner, TestLoader

        import shapely.tests
        tests = TestLoader().loadTestsFromName('test_suite', shapely.tests)
        runner = TextTestRunner(verbosity=2)
        result = runner.run(tests)

        if not result.wasSuccessful():
            sys.exit(1)
예제 #13
0
    def run(self):
        # Force an in-place build for testing speedups
        cmd = self.reinitialize_command('build_ext')
        setattr(cmd, 'inplace', 1)
        self.run_command('build_ext')

        if sys.version_info[0:2] <= (2, 6):
            try:
                from unittest2 import TextTestRunner, TestLoader
            except ImportError:
                raise ImportError(
                    "unittest2 is required to run tests with python-%d.%d" %
                    sys.version_info[0:2])
        else:
            from unittest import TextTestRunner, TestLoader

        # Handle if --speedups={true|false} specified on command line
        if self.speedups is not None:
            import shapely.speedups
            if self.speedups == 'true':
                if not shapely.speedups.available:
                    print("speedups are forced but unavailable")
                    sys.exit(1)
                shapely.speedups.enable()
            elif self.speedups == 'false':
                shapely.speedups.available = False
                shapely.speedups.disable()
            else:
                print("Unrecognized speedups value: {}".format(self.speedups))
                sys.exit(1)
        import shapely.tests
        tests = TestLoader().loadTestsFromName('test_suite', shapely.tests)
        runner = TextTestRunner(verbosity=2)
        result = runner.run(tests)

        if not result.wasSuccessful():
            sys.exit(1)
예제 #14
0
파일: ctest_run.py 프로젝트: danielfmva/ert
def runTestCase(tests):
    test_result = TextTestRunner(verbosity=0).run(tests)
    if test_result.errors or test_result.failures:
        for (test, trace_back) in test_result.errors:
            sys.stderr.write("=================================================================\n")
            sys.stderr.write("Test:%s error \n" % test.id())
            sys.stderr.write("%s\n" % trace_back)

        for (test, trace_back) in test_result.failures:
            sys.stderr.write("=================================================================\n")
            sys.stderr.write("Test:%s failure \n" % test.id())
            sys.stderr.write("%s\n" % trace_back)

        return False
    else:
        return True
예제 #15
0
 def __runner_run(self, item):
     # 开始run test
     test_suites = suite.TestSuite(item)
     runner = TextTestRunner(verbosity=1)
     result = runner.run(test_suites)
     self.all_result.append(result)
예제 #16
0
파일: runtests.py 프로젝트: jumboTest/test
def runtests(test_names,
             test_dir='.',
             count_only=False,
             report_format='console',
             browser_type='Firefox',
             javascript_disabled=False,
             browsermob_enabled=False,
             shared_directory=None,
             screenshots_on=False,
             failfast=False,
             debug=False,
             webdriver_remote_url=None,
             browser_version='',
             browser_platform='ANY',
             session_name=None,
             extended=False):
    
    if allscrewedup : print "ENTERING runtests"

    if test_dir == 'selftests':
        # XXXX horrible hardcoding
        # selftests should be a command instead
        package_dir = os.path.dirname(__file__)
        test_dir = os.path.join(package_dir, 'selftests')

    test_dir = _get_full_path(test_dir)
            
    if not os.path.isdir(test_dir):
        msg = 'Specified directory %r does not exist' % test_dir
        print msg
        sys.exit(1)

    shared_directory = find_shared_directory(test_dir, shared_directory)
    config.shared_directory = shared_directory
    sys.path.append(shared_directory)

    # config.results_directory = _get_full_path('results')
    #config.browsermob_enabled = browsermob_enabled

    test_names = set(test_names)
    suites = get_suites(test_names, test_dir, shared_directory, count_only, browser_type, browser_version,
                    browser_platform, session_name, javascript_disabled,
                    webdriver_remote_url, screenshots_on, failfast, debug,
                    extended=extended,
                    )

    alltests = TestSuite(suites)
    
    print alltests.__iter__

    print ''
    print '  %s test cases loaded\n' % alltests.countTestCases()
    print '--------------------------------------------------------------'

    if not alltests.countTestCases():
        print 'Error: Did not find any tests'
        sys.exit(1)

    if count_only:
        print 'Count-Only Enabled, Not Running Tests'
        sys.exit(0)

    print "Report Format: ", report_format
    if report_format == 'xml':
        print "Create Results Dir if does not exist"
        _make_results_dir()
        fp = None
        print "config.config.xml_results_file:", config.xml_results_file
        if config.xml_results_file is None:
            fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb')
        else:
            fp = file(config.xml_results_file, 'wb')
        # XXX failfast not supported in XMLTestRunner
        runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2)
    elif report_format == 'html':
        _make_results_dir()
        fp = file(os.path.join(config.results_directory, 'results.html'), 'wb')
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp,
            title='NSUI Test Report',
            description='Report for this test run, please expand the \
            pass/fail for detailed results',
            dirTestScreenshots = config.results_directory
            )
    else:
        runner = TextTestRunner(verbosity=2, failfast=failfast)

    try:
        runner.run(alltests)
        #return runner._makeResult()
    except KeyboardInterrupt:
        print >> sys.stderr, 'Test run interrupted'
    finally:
        # XXX should warn on cases that were specified but not found
        pass
예제 #17
0
 def runTestsInClass(classpath, test_verbosity=3):
     klass = ErtTestRunner.importClass(classpath)
     loader = TestLoader()
     tests = loader.loadTestsFromTestCase(klass)
     testRunner = TextTestRunner(verbosity=test_verbosity)
     testRunner.run(tests)
예제 #18
0
    try:
        import mock

    except ImportError:
        raise ImportError("The BatchApps Python Client test suite requires "
                          "the mock package to run on Python 3.2 and below.\n"
                          "Please install this package to continue.")

try:
    from teamcity import is_running_under_teamcity
    from teamcity.unittestpy import TeamcityTestRunner
    TC_BUILD = is_running_under_teamcity()

except ImportError:
    TC_BUILD = False

if __name__ == '__main__':

    if TC_BUILD:
        runner = TeamcityTestRunner()
    else:
        runner = TextTestRunner(verbosity=2)

    test_dir = os.path.dirname(__file__)
    top_dir = os.path.dirname(os.path.dirname(test_dir))
    test_loader = TestLoader()
    suite = test_loader.discover(test_dir,
                                 pattern="unittest_*.py",
                                 top_level_dir=top_dir)
    runner.run(suite)
예제 #19
0
def runtests(test_names, test_dir='.', collect_only=False,
             report_format='console', browser_type='Firefox',
             javascript_disabled=False,
             shared_directory=None, screenshots_on=False, failfast=False,
             debug=False, webdriver_remote_url=None, device='', version='',
             browser_platform='ANY', session_name=None,
             browserstack_enabled=False, vagrant_enabled=False,
             saucelabs_enabled=False, custom_options=None,
             extended=False, skip_tracking=False):

    if test_dir == 'selftests':
        # XXXX horrible hardcoding
        # selftests should be a command instead
        package_dir = os.path.dirname(__file__)
        test_dir = os.path.join(package_dir, 'selftests')

    test_dir = _get_full_path(test_dir)
    if not os.path.isdir(test_dir):
        msg = 'Specified directory %r does not exist' % test_dir
        print msg
        sys.exit(1)

    shared_directory = find_shared_directory(test_dir, shared_directory)
    config.shared_directory = shared_directory
    sys.path.append(shared_directory)

    config.results_directory = _get_full_path('results')
    config.saucelabs_enabled = saucelabs_enabled
    config.browserstack_enabled = browserstack_enabled
    config.vagrant_enabled = vagrant_enabled

    test_names = set(test_names)

    suites = get_suites(test_names, test_dir, shared_directory, collect_only,
                        browser_type, device, version, browser_platform,
                        session_name, javascript_disabled, webdriver_remote_url,
                        screenshots_on, failfast, debug, saucelabs_enabled=saucelabs_enabled,
                        browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled,
                        skip_tracking=skip_tracking, custom_options=custom_options, extended=extended
                        )

    alltests = TestSuite(suites)

    if not alltests.countTestCases():
        print 'Error: Did not find any tests'
        sys.exit(1)

    if collect_only:
        print 'Collect-Only Enabled, Not Running Tests...\n'
        print 'Tests Collected:'
        print '-' * 16
        for t in sorted(testtools.testsuite.iterate_tests(alltests)):
            print t.id()
        sys.exit(0)

    if report_format == 'xml':
        _make_results_dir()
        fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb')
        # XXX failfast not supported in XMLTestRunner
        runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2)

    elif report_format == 'html':
        _make_results_dir()
        fp = file(os.path.join(config.results_directory, 'results.html'), 'wb')
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp, title='SST Test Report', verbosity=2, failfast=failfast
        )

    else:
        if config.email_notification_enabled:
            stream = cStringIO.StringIO()
        else:
            stream = sys.stderr
        runner = TextTestRunner(verbosity=2, failfast=failfast, stream=stream,
                                resultclass=SSTTextTestResult)

    try:
        return runner.run(alltests)
    except KeyboardInterrupt:
        print >> sys.stderr, 'Test run interrupted'
    finally:
        # XXX should warn on cases that were specified but not found
        pass
예제 #20
0
    def runTestSuite(tests, test_verbosity=3):
        test_runner = TextTestRunner(verbosity=test_verbosity)
        result = test_runner.run(tests)

        return result.wasSuccessful()
    except ImportError:
        raise ImportError("The ADAL test suite requires the unittest2 "
                          "package to run on Python 2.6 and below.\n"
                          "Please install this package to continue.")
else:
    from unittest import TestLoader, TextTestRunner

if sys.version_info[:2] >= (3, 3, ):
    from unittest import mock
else:
    try:
        import mock

    except ImportError:
        raise ImportError("The ADAL test suite requires the mock "
                          "package to run on Python 3.2 and below.\n"
                          "Please install this package to continue.")


if __name__ == '__main__':

    runner = TextTestRunner(verbosity=2)

    test_dir = os.path.dirname(__file__)
    top_dir = os.path.dirname(os.path.dirname(test_dir))
    test_loader = TestLoader()
    suite = test_loader.discover(test_dir,
                                 pattern="test_*.py",
                                 top_level_dir=top_dir)
    runner.run(suite)
예제 #22
0
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# 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.

import os
import sys

if sys.version_info[:2] <= (2,6):
    from unittest2 import TestLoader, TextTestRunner
else:
    from unittest import TestLoader, TextTestRunner


testdir = os.path.split(os.path.abspath(__file__))[0]
topdir = os.path.split(testdir)[0]
libdir = os.path.join(topdir, 'lib')

os.chdir(testdir)
sys.path.insert(0, libdir)

loader = TestLoader()
tests = loader.discover('.', 'flow_*.py')

runner = TextTestRunner(verbosity=2, buffer=True)
runner.run(tests)
예제 #23
0
 def runTestsInClass(classpath, test_verbosity=3):
     klass = ErtTestRunner.importClass(classpath)
     loader = TestLoader()
     tests = loader.loadTestsFromTestCase(klass)
     testRunner = TextTestRunner(verbosity=test_verbosity)
     testRunner.run(tests)
예제 #24
0
                          "package to run on Python 2.6 and below.\n"
                          "Please install this package to continue.")
else:
    from unittest import TestLoader, TextTestRunner

if sys.version_info[:2] >= (
        3,
        3,
):
    from unittest import mock
else:
    try:
        import mock

    except ImportError:
        raise ImportError("The ADAL test suite requires the mock "
                          "package to run on Python 3.2 and below.\n"
                          "Please install this package to continue.")

if __name__ == '__main__':

    runner = TextTestRunner(verbosity=2)

    test_dir = os.path.dirname(__file__)
    top_dir = os.path.dirname(os.path.dirname(test_dir))
    test_loader = TestLoader()
    suite = test_loader.discover(test_dir,
                                 pattern="test_*.py",
                                 top_level_dir=top_dir)
    runner.run(suite)
def runtests(test_names, test_dir='.', file_match='*.py',
             report_format='console', browser_type='Firefox',
             javascript_disabled=False, browsermob_enabled=False,
             shared_directory=None, screenshots_on=False, failfast=False,
             debug=False, webdriver_remote_url=None, browser_version='',
             browser_platform='ANY', session_name=None,
             extended=False):

    if test_dir == 'selftests':
        # XXXX horrible hardcoding
        # selftests should be a command instead
        package_dir = os.path.dirname(__file__)
        test_dir = os.path.join(package_dir, 'selftests')

    test_dir = _get_full_path(test_dir)
    if not os.path.isdir(test_dir):
        msg = 'Specified directory %r does not exist' % test_dir
        print msg
        sys.exit(1)

    shared_directory = find_shared_directory(test_dir, shared_directory)
    config.shared_directory = shared_directory
    sys.path.append(shared_directory)

    config.results_directory = _get_full_path('results')

    config.browsermob_enabled = browsermob_enabled

    found_tests = set()
    test_names = set(test_names)

    suites = (
        get_suite(
            test_names, root, file_match, browser_type, browser_version,
            browser_platform, session_name, javascript_disabled,
            webdriver_remote_url, screenshots_on, found_tests, failfast, debug,
            extended=extended,
        )
        for root, _, _ in os.walk(test_dir, followlinks=True)
        if os.path.abspath(root) != shared_directory and
        not os.path.abspath(root).startswith(shared_directory + os.path.sep)
        and not os.path.split(root)[1].startswith('_')
    )

    alltests = TestSuite(suites)

    print ''
    print '  %s test cases loaded\n' % alltests.countTestCases()
    print '--------------------------------------------------------------'

    if not alltests.countTestCases():
        print 'Error: Did not find any tests'
        sys.exit(1)

    if report_format == 'xml':
        _make_results_dir()
        fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb')
        # XXX failfast not supported in XMLTestRunner
        runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2)

    elif report_format == 'html':
        _make_results_dir()
        fp = file(os.path.join(config.results_directory, 'results.html'), 'wb')
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp, title='SST Test Report', verbosity=2, failfast=failfast
        )

    else:
        runner = TextTestRunner(verbosity=2, failfast=failfast)

    try:
        runner.run(alltests)
    except KeyboardInterrupt:
        print >> sys.stderr, 'Test run interrupted'
    finally:
        missing = test_names - found_tests
        for name in missing:
            msg = 'Warning: test %r not found' % name
            print >> sys.stderr, msg
예제 #26
0
def runTestsInDirectory(path="."):
    loader = TestLoader()
    tests = loader.discover(path)
    testRunner = TextTestRunner()
    testRunner.run(tests)
예제 #27
0
def runTestsInClass(classpath):
    klass = importClass(classpath)
    loader = TestLoader()
    tests = loader.loadTestsFromTestCase(klass)
    testRunner = TextTestRunner()
    testRunner.run(tests)
예제 #28
0
    def runTestSuite(tests, test_verbosity=3):
        test_runner = TextTestRunner(verbosity=test_verbosity)
        result = test_runner.run(tests)

        return result.wasSuccessful()
예제 #29
0
#!/usr/bin/env python
import os
import sys
from unittest2 import TestLoader, TextTestRunner


if __name__ == '__main__':
    tests_dir = os.path.dirname(os.path.abspath(__file__))
    authorize_dir = os.path.join(tests_dir, os.path.pardir)
    sys.path.append(authorize_dir)
    suite = TestLoader().discover(tests_dir)
    runner = TextTestRunner(verbosity=1)
    result = runner.run(suite)
    sys.exit(not result.wasSuccessful())
예제 #30
0
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# 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.

import os
import sys

if sys.version_info[:2] <= (2, 6):
    from unittest2 import TestLoader, TextTestRunner
else:
    from unittest import TestLoader, TextTestRunner

testdir = os.path.split(os.path.abspath(__file__))[0]
topdir = os.path.split(testdir)[0]
libdir = os.path.join(topdir, 'lib')

os.chdir(testdir)
sys.path.insert(0, libdir)

loader = TestLoader()
tests = loader.discover('.', 'flow_*.py')

runner = TextTestRunner(verbosity=2, buffer=True)
runner.run(tests)