test/unittest_checkers_jslint.py
author David Douard <david.douard@logilab.fr>
Wed, 14 May 2014 22:28:57 +0200
changeset 1520 0abe241164e2
parent 1501 a45f5a997ab2
permissions -rw-r--r--
[test] fix tests when executed in an apycot environment ie. when tests are executed from sources towards an installed apycot. The fix consist mainly in "moving" the input_path function from testutils.py (which is part of the installed modules) into unittest_checkers.py so we are sure we look for test data files relatively to the test directory (and not the location of the installation).

#!/usr/bin/python

from logilab.common.testlib import TestSuite, TestCase, unittest_main
from unittest_checkers import FileCheckerTest, WRITER

try:
    import cubes.apycot
    from checkers.apycot.jslint import JsLintChecker, JsLintParser

    def load_tests(loader, tests, pattern):
        testsuite = TestSuite()
        addTest = testsuite.addTest
        # JSLint
        js_lint = JsLintChecker(WRITER)
        addTest(FileCheckerTest(js_lint, ['jscript/correct'], 'chks_test_dir_success'))

        addTest(FileCheckerTest(js_lint, ['jscript/bad/',],
                                'chks_test_dir_failure'))
        return testsuite

except ImportError:
    class NoTest(TestCase):
        def test(self):
            self.skipTest('install rhino to enable jslint')


if __name__ == '__main__':
    unittest_main()