Exemplo n.º 1
0
    def test__1(self):

        """Tests the following functions:

        - :func:`hkutils.set_log`
        - :func:`hkutils.log`
        """

        # We use a custom log function
        old_log_fun = hkutils.log_fun
        def log_fun(*args):
            log.append(list(args))
        hkutils.set_log(log_fun)

        # Test logging
        log = []
        hkutils.log('first line', 'second line')
        hkutils.log('third line')
        self.assertEqual(
            log,
            [['first line', 'second line'],
             ['third line']])

        # Setting the original logging function back
        hkutils.set_log(old_log_fun)
Exemplo n.º 2
0
def main(args):

    hkutils.set_log(False)
    if len(args) > 0 and args[0] in ['-h', '--help']:
        sys.stdout.write(__doc__)
    elif args == []:
        testmodules = collect_testmodules()
        suites = \
            [ unittest.TestLoader().loadTestsFromModule(__import__(modname))
              for modname in testmodules ]
        suite = unittest.TestSuite(suites)
        unittest.TextTestRunner(verbosity=0).run(suite)
    elif len(args) == 3:
        modname, testcasename, funname = args
        suite = unittest.TestSuite()
        testcase = getattr(__import__(modname), testcasename)
        suite.addTest(testcase(funname))
        unittest.TextTestRunner(verbosity=0).run(suite)
    else:
        print 'Incorrect arguments.\n' \
              'Run "python test.py --help" for help.'
Exemplo n.º 3
0
        # hardcode these values in the tests.
        g.options.js_files = ['static/js/myjs.js']
        g.options.cssfiles = ['static/css/mycss1.css', 'static/css/mycss2.css']
        g.options.favicon = 'static/images/myicon.ico'

        self.assertTextStructsAreEqual(
            g.print_html_head_content(),
            ('    <link rel="stylesheet" href="/static/css/mycss1.css" '
             'type="text/css" />\n'
             '    <link rel="stylesheet" href="/static/css/mycss2.css" '
             'type="text/css" />\n'
             '    <link rel="shortcut icon" '
             'href="/static/images/myicon.ico">\n'))

    def test_print_postitem_flat(self):
        """Inherited test case that we don't want to execute because it would
        fail."""

        pass

    def test_print_postitem_inner(self):
        """Inherited test case that we don't want to execute because it would
        fail."""

        pass


if __name__ == '__main__':
    hkutils.set_log(False)
    unittest.main()