コード例 #1
0
def load_tests(loader, tests, pattern):
    # Have to import this in the function, because the module does
    # initialization on import! ugh.
    from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter

    # Load our plugin.
    linter.load_plugin_modules(['edx_lint.pylint'])

    # Configure the linter that runs the tests.

    # This line prevents pylint from complaining about missing __revision__ in
    # all the test files. But is this removing other required attributes that
    # maybe we do want to check for?
    linter.global_set_option('required-attributes', ())

    here = os.path.dirname(os.path.abspath(__file__))

    tests = make_tests(
        input_dir=os.path.join(here, 'input'),
        msg_dir=os.path.join(here, 'messages'),
        filter_rgx=None,
        callbacks=[cb_test_gen(LintTestUsingFile)],
    )

    cls = testlib.TestSuite
    return cls(unittest.makeSuite(test, suiteClass=cls) for test in tests)
コード例 #2
0
def load_tests(unused_loader, tests, unused_pattern):
    """Loads tests for the pylint test loader.

    This function is automatically run by pylint's test runner, and is called
    with three arguments, two of which we don't need.

    """
    # Have to import this in the function, because the module does
    # initialization on import! ugh.
    from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter

    # Load our plugin.
    linter.load_plugin_modules(['edx_lint.pylint'])
    linter.global_set_option('required-attributes', ())

    here = os.path.dirname(os.path.abspath(__file__))

    tests = make_tests(
        input_dir=os.path.join(here, 'input'),
        msg_dir=os.path.join(here, 'messages'),
        filter_rgx=None,
        callbacks=[cb_test_gen(LintTestUsingFile)],
    )

    cls = unittest.TestSuite
    return cls(unittest.makeSuite(test, suiteClass=cls) for test in tests)
コード例 #3
0
ファイル: test_func.py プロジェクト: 4sp1r3/pylint-common
from os.path import join, dirname, abspath
import unittest
from pylint.testutils import make_tests, LintTestUsingModule, LintTestUsingFile, cb_test_gen, linter
import sys


INPUT_DIR = join(dirname(abspath(__file__)), 'input')
MESSAGES_DIR = join(dirname(abspath(__file__)), 'messages')
CALLBACKS = [cb_test_gen(LintTestUsingModule), cb_test_gen(LintTestUsingFile)]
FILTER_RGX = None


linter.load_plugin_modules(['pylint_common'])
linter.global_set_option('required-attributes', ())  # remove required __revision__


def suite():
    return unittest.TestSuite([unittest.makeSuite(test, suiteClass=unittest.TestSuite)
                              for test in make_tests(INPUT_DIR, MESSAGES_DIR,
                                                     FILTER_RGX, CALLBACKS)])

if __name__=='__main__':
    if len(sys.argv) > 1:
        FILTER_RGX = sys.argv[1]
        del sys.argv[1]
    unittest.main(defaultTest='suite')

コード例 #4
0
ファイル: test_func.py プロジェクト: pexip/os-pylint-twisted
import os
import unittest
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter

HERE = os.path.dirname(os.path.abspath(__file__))

linter.load_plugin_modules(['pylint_twisted'])
# remove required __revision__
linter.global_set_option('required-attributes', ())
# We need to ensure that pylint_twisted works for multiple modules on one line
linter.global_set_option('disable', "multiple-imports")


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True


def tests(input_dir, messages_dir):
    callbacks = [cb_test_gen(LintTestUsingFile)]

    input_dir = os.path.join(HERE, input_dir)
    messages_dir = os.path.join(HERE, messages_dir)

    return make_tests(input_dir, messages_dir, None, callbacks)

コード例 #5
0
ファイル: test_func.py プロジェクト: aisapatino/pylint-django
from django.conf import settings
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter
from pylint_django.compat import django_version


settings.configure()


HERE = os.path.dirname(os.path.abspath(__file__))


linter.load_plugin_modules(['pylint_django'])
# Disable some things on Python2.6, since we use a different pylint version here
# (1.3 on Python2.6, 1.4+ on later versions)
if sys.version_info < (2, 7):
    linter.global_set_option('required-attributes', ())
    linter.global_set_option('disable', ('E0012',))


SKIP_TESTS_FOR_DJANGO_VERSION = {
    # if the second value is False, skip the test, otherwise run it
    ('func_noerror_protected_meta_access', django_version >= (1, 8)),
}


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
コード例 #6
0
ファイル: test_func.py プロジェクト: jschaf/pylint-werkzeug
import os
import unittest
from logilab.common import testlib
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter


HERE = os.path.dirname(os.path.abspath(__file__))

linter.load_plugin_modules(['pylint_werkzeug'])
# remove required __revision__
linter.global_set_option('required-attributes', ())


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True


def tests(input_dir, messages_dir):
    callbacks = [cb_test_gen(LintTestUsingFile)]

    input_dir = os.path.join(HERE, input_dir)
    messages_dir = os.path.join(HERE, messages_dir)

    return make_tests(input_dir, messages_dir, None, callbacks)

コード例 #7
0
import os
import unittest
from django.conf import settings
from logilab.common import testlib
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter


settings.configure()


HERE = os.path.dirname(os.path.abspath(__file__))


linter.load_plugin_modules(['pylint_django'])
linter.global_set_option('required-attributes', ())  # remove required __revision__


def tests():
    callbacks = [cb_test_gen(LintTestUsingFile)]

    input_dir = os.path.join(HERE, 'input')
    messages_dir = os.path.join(HERE, 'messages')

    return make_tests(input_dir, messages_dir, None, callbacks)


def suite():
    return testlib.TestSuite([unittest.makeSuite(test, suiteClass=testlib.TestSuite)
                              for test in tests()])
コード例 #8
0
ファイル: test_func.py プロジェクト: vinaypai/pylint-django
import os
import sys
import unittest
from django.conf import settings
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter
from pylint_django.compat import django_version

settings.configure()

HERE = os.path.dirname(os.path.abspath(__file__))

linter.load_plugin_modules(['pylint_django'])
# Disable some things on Python2.6, since we use a different pylint version here
# (1.3 on Python2.6, 1.4+ on later versions)
if sys.version_info < (2, 7):
    linter.global_set_option('required-attributes', ())
    linter.global_set_option('disable', ('E0012', ))

SKIP_TESTS_FOR_DJANGO_VERSION = {
    # if the second value is False, skip the test, otherwise run it
    ('func_noerror_protected_meta_access', django_version >= (1, 8)),
}


def module_exists(module_name):
    try:
        __import__(module_name)
    except ImportError:
        return False
    else:
        return True