How to use the unittest2.TextTestRunner 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 quattor / aquilon / tests / broker / test_del_metacluster.py View on Github external
self.wait_notification(basetime, 0)

    def testverifyall(self):
        command = ["show_metacluster", "--all"]
        out = self.commandtest(command)
        self.matchclean(out, "Metacluster: utmc", command)

    def testdelnotfound(self):
        command = ["del_metacluster",
                   "--metacluster=metacluster-does-not-exist"]
        self.notfoundtest(command)


if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDelMetaCluster)
    unittest.TextTestRunner(verbosity=2).run(suite)
github timlau / FedoraReview / test / run-tests.py View on Github external
if fr_testcase.NO_NET:
    print "Warning:  No network available, only some tests run"
if not 'REVIEW_LOGLEVEL' in os.environ:
    print "Warning:  REVIEW_LOGLEVEL not set, lot's of output ahead."
if fr_testcase.FAST_TEST:
    print "Warning: slow tests skipped"


Mock.init()

testFail = 0
for t in 'Misc', 'Bugzilla', 'Ext', 'Options', 'Checks', 'RChecks', \
         'Regressions', 'Dist', 'Deps':
    test = eval('unittest.TestLoader().loadTestsFromTestCase(Test%s)' % t)
    result = unittest.TextTestRunner(verbosity=VERBOSITY).run(test)
    testFail = testFail + len(result.errors) + len(result.failures)

sys.exit(testFail)
github qubole / spark-on-lambda / python / pyspark / streaming / tests.py View on Github external
% kinesis_asl_assembly_dir) +
            "You need to build Spark with 'build/sbt -Pkinesis-asl "
            "assembly/package streaming-kinesis-asl-assembly/assembly'"
            "or 'build/mvn -Pkinesis-asl package' before running this test.")

    sys.stderr.write("Running tests: %s \n" % (str(testcases)))
    failed = False
    for testcase in testcases:
        sys.stderr.write("[Running %s]\n" % (testcase))
        tests = unittest.TestLoader().loadTestsFromTestCase(testcase)
        if xmlrunner:
            result = xmlrunner.XMLTestRunner(output='target/test-reports', verbosity=3).run(tests)
            if not result.wasSuccessful():
                failed = True
        else:
            result = unittest.TextTestRunner(verbosity=3).run(tests)
            if not result.wasSuccessful():
                failed = True
    sys.exit(failed)
github quattor / aquilon / tests / broker / test_del_os.py View on Github external
"--osname=utos", "--osversion=1.0"]
        self.noouttest(command)

    def testverifydelos(self):
        command = "show os --osname utos --archetype=utarchetype1"
        self.notfoundtest(command.split(" "))

    def testdelinvalid(self):
        command = ["del_os", "--archetype=utarchetype1",
                   "--osname=os-does-not-exist", "--osvers=1.0"]
        self.notfoundtest(command)


if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDelOS)
    unittest.TextTestRunner(verbosity=2).run(suite)
github quattor / aquilon / tests / broker / test_map_dns_domain.py View on Github external
def test_450_verify_positions(self):
        command = ["search", "dns", "domain", "map", "--room", "utroom1"]
        out = self.commandtest(command)
        self.searchoutput(out,
                          r"DNS Domain: td1.aqd-unittest.ms.com Map: Room utroom1\s*"
                          r"Position: 0\s*"
                          r"DNS Domain: td2.aqd-unittest.ms.com Map: Room utroom1\s*"
                          r"Position: 1\s*"
                          r"DNS Domain: aqd-unittest.ms.com Map: Room utroom1\s*"
                          r"Position: 2\s*",
                          command)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMapDnsDomain)
    unittest.TextTestRunner(verbosity=2).run(suite)
github etingof / pyasn1 / tests / codec / cer / test_decoder.py View on Github external
assert s[1][0] == 12

    def testDecodeOpenTypesUnknownId(self):
        s, r = decoder.decode(
            ints2octs( (48, 10, 2, 1, 3, 49, 5, 131, 3, 2, 1, 12)),
            asn1Spec=self.s, decodeOpenTypes=True
        )
        assert not r
        assert s[0] == 3
        assert s[1][0] == univ.OctetString(hexValue='02010C')


suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)
github the-blue-alliance / the-blue-alliance / run_tests.py View on Github external
def run_suite(suite):
    sio = StringIO.StringIO()
    testresult = unittest2.TextTestRunner(sio, verbosity=2).run(suite)
    output = sio.getvalue()
    with lock:
        total_run.value += testresult.testsRun
        if not testresult.wasSuccessful():
            fail_count.value += 1
        print output.encode('utf-8')
github etingof / pysmi / tests / test_valuedeclaration_smiv2_pysnmp.py View on Github external
self.ctx['testValue2'].getName(),
            (1, 3),
            'bad value'
        )

    def testValueDeclarationName3(self):
        self.assertEqual(
            self.ctx['testValue3'].getName(),
            (1, 3, 6, 1, 2),
            'bad value'
        )

suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)
github timlau / FedoraReview / test / test_dist.py View on Github external
'''
        os.chdir('..')
        check_call('./try-fedora-review -m fedora-18-i386' +
                       ' -o "--without tests"' +
                       ' -rn dist/fedora-review*.src.rpm',
                   shell=True)


if __name__ == '__main__':
    if len(sys.argv) > 1:
        suite = unittest.TestSuite()
        for test in sys.argv[1:]:
            suite.addTest(TestDist(test))
    else:
        suite = unittest.TestLoader().loadTestsFromTestCase(TestDist)
    unittest.TextTestRunner(verbosity=2).run(suite)
github lyda / misspell-check / setup.py View on Github external
def run(self):
    test_dir = os.path.join(BASE_DIR, 'tests')

    tests = unittest.TestLoader().discover(test_dir)
    runner = unittest.TextTestRunner(verbosity=2)
    result = runner.run(tests)
    if not result.wasSuccessful():
      sys.exit(1)