Пример #1
0
    def testRunner(self):
        # Creating a TextTestRunner with the appropriate argument should
        # register the TextTestResult it creates
        runner = unittest.TextTestRunner(stream=StringIO())

        result = runner.run(unittest.TestSuite())
        self.assertIn(result, unittest.signals._results)
Пример #2
0
    def testFailFastSetByRunner(self):
        runner = unittest.TextTestRunner(stream=StringIO(), failfast=True)

        def test(result):
            self.assertTrue(result.failfast)

        runner.run(test)
Пример #3
0
    def testRunnerRegistersResult(self):
        class Test(unittest.TestCase):
            def testFoo(self):
                pass

        originalRegisterResult = unittest.runner.registerResult

        def cleanup():
            unittest.runner.registerResult = originalRegisterResult

        self.addCleanup(cleanup)

        result = unittest.TestResult()
        runner = unittest.TextTestRunner(stream=StringIO())
        # Use our result object
        runner._makeResult = lambda: result

        self.wasRegistered = 0

        def fakeRegisterResult(thisResult):
            self.wasRegistered += 1
            self.assertEqual(thisResult, result)

        unittest.runner.registerResult = fakeRegisterResult

        runner.run(unittest.TestSuite())
        self.assertEqual(self.wasRegistered, 1)
Пример #4
0
 def test_init(self):
     runner = unittest.TextTestRunner()
     self.assertFalse(runner.failfast)
     self.assertFalse(runner.buffer)
     self.assertEqual(runner.verbosity, 1)
     self.assertTrue(runner.descriptions)
     self.assertEqual(runner.resultclass, unittest.TextTestResult)
Пример #5
0
 def test_ExitAsDefault(self):
     self.assertRaises(
         SystemExit,
         unittest.main,
         argv=["foobar"],
         testRunner=unittest.TextTestRunner(stream=StringIO()),
         testLoader=self.FooBarLoader())
Пример #6
0
 def test_NonExit(self):
     program = unittest.main(
         exit=False,
         argv=["foobar"],
         testRunner=unittest.TextTestRunner(stream=StringIO()),
         testLoader=self.FooBarLoader())
     self.assertTrue(hasattr(program, 'result'))
Пример #7
0
 def testOldResultWithRunner(self):
     class Test(unittest.TestCase):
         def testFoo(self):
             pass
     runner = unittest.TextTestRunner(resultclass=OldResult,
                                       stream=StringIO())
     # This will raise an exception if TextTestRunner can't handle old
     # test result objects
     runner.run(Test('testFoo'))
Пример #8
0
 def test_pickle_unpickle(self):
     # Issue #7197: a TextTestRunner should be (un)pickleable. This is
     # required by test_multiprocessing under Windows (in verbose mode).
     from StringIO import StringIO as PickleableIO
     # cStringIO objects are not pickleable, but StringIO objects are.
     stream = PickleableIO("foo")
     runner = unittest.TextTestRunner(stream)
     for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
         s = pickle.dumps(runner, protocol=protocol)
         obj = pickle.loads(s)
         # StringIO objects never compare equal, a cheap test instead.
         self.assertEqual(obj.stream.getvalue(), stream.getvalue())
Пример #9
0
    def test_resultclass(self):
        def MockResultClass(*args):
            return args

        STREAM = object()
        DESCRIPTIONS = object()
        VERBOSITY = object()
        runner = unittest.TextTestRunner(STREAM,
                                         DESCRIPTIONS,
                                         VERBOSITY,
                                         resultclass=MockResultClass)
        self.assertEqual(runner.resultclass, MockResultClass)

        expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
        self.assertEqual(runner._makeResult(), expectedresult)
Пример #10
0
    def testBufferAndFailfast(self):
        class Test(unittest.TestCase):
            def testFoo(self):
                pass

        result = unittest.TestResult()
        runner = unittest.TextTestRunner(stream=StringIO(),
                                         failfast=True,
                                         buffer=True)
        # Use our result object
        runner._makeResult = lambda: result
        runner.run(Test('testFoo'))

        self.assertTrue(result.failfast)
        self.assertTrue(result.buffer)
Пример #11
0
 def getRunner(self):
     return unittest.TextTestRunner(resultclass=resultFactory,
                                    stream=StringIO())
Пример #12
0
 def run_suite(self, suite, **kwargs):
     return redgreenunittest.TextTestRunner(
         verbosity=self.verbosity, failfast=self.failfast).run(suite)
Пример #13
0
import redgreenunittest as unittest
import calculator.calc


class CalculatorTests(unittest.TestCase):
    def setUp(self):
        print 'setup...'

    def tearDown(self):
        print 'tear down...'

    def test_runs(self):
        calcClass = calculator.calc.Calculator()
        self.assertEqual(2, calcClass.add(1, 1))


if __name__ == '__main__':
    # all test run
    # unittest.main()
    runner = unittest.TextTestRunner()
    runner.run(unittest.makeSuite(CalculatorTests, 'test'))
Пример #14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This file is part of Uxie.

Uxie - Pokemon Showdown's usage stats database builder
Copyright (C) 2016 Kewin Dousse (Protectator)

Licensed under the MIT License. See file LICENSE in the project root for license information.
"""
import sys
import redgreenunittest as unittest
from tests.testparsers import UsageTest, MetagameTest, MovesetTest, LeadsTest, ChaosTest
from tests.testdatabases import MysqlTest
from tests.testfeeder import FeederTest


def suite():
    return unittest.TestSuite(
        (unittest.makeSuite(MysqlTest), unittest.makeSuite(UsageTest),
         unittest.makeSuite(MetagameTest), unittest.makeSuite(MovesetTest),
         unittest.makeSuite(LeadsTest), unittest.makeSuite(ChaosTest),
         unittest.makeSuite(FeederTest)))


if __name__ == '__main__':
    ret = not unittest.TextTestRunner(verbosity=2).run(suite()).wasSuccessful()
    sys.exit(ret)
Пример #15
0
    suite.addTest(TestMetaxEtsin("testDeleteDataset"))

    suite.addTest(TestIDAMetax("testFreezeFile"))
    suite.addTest(TestIDAMetax("testUnFreezeFile"))
    suite.addTest(TestIDAMetax("testDeleteFile"))

    #suite.addTest(TestMetaxQuvain("testCreateDataset"))
    #suite.addTest(TestMetaxQuvain("testUpdateDateset"))
    #suite.addTest(TestMetaxQuvain("testDeleteDataset"))

    suite.addTest(TestMetaxDPress("testPreserveDataset"))
    suite.addTest(TestMetaxDPress("testRejectDataset"))
    suite.addTest(TestMetaxDPress("testRemoveDataset"))
    suite.addTest(TestMetaxDPress("testResetDataset"))

    runner = unittest.TextTestRunner(verbosity=2)

    runner.resultclass = JsonTestResult

    result = runner.run(suite)

    elapsed_time = time.time() - start_time

    #  print json output
    result_dict = result.jsonify()
    count, total = result_count(result_dict)

    print("-----" * 20)
    print("\t\t\tSUMMARY ")
    print("-----" * 20)
    print("\n\t\t\tTotal   == ", total)