Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
def suite():
    input_dir = os.path.join(os.path.dirname(__file__), 'input')
    msg_dir = os.path.join(os.path.dirname(__file__), 'messages')
    linter.load_plugin_modules(['django_linter'])
    linter.set_option('disable', 'R0901,C0111')
    return unittest.TestSuite([
        unittest.makeSuite(test, suiteClass=unittest.TestSuite)
        for test in make_tests(
            input_dir, msg_dir, None, [cb_test_gen(LintTestUsingFile)])])
Exemplo n.º 4
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, and disable messages we don't want noising up our tests.
    linter.load_plugin_modules(['edx_lint.pylint'])
    linter.disable("missing-module-attribute")

    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)
Exemplo n.º 5
0
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')

Exemplo n.º 6
0
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)

Exemplo n.º 7
0
from os.path import join, dirname, abspath
import unittest
from logilab.common import testlib
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 testlib.TestSuite(
        [
            unittest.makeSuite(test, suiteClass=testlib.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]
    testlib.unittest_main(defaultTest="suite")
Exemplo n.º 8
0
import os
import unittest
from django.conf import settings
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'])


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)


def suite():
Exemplo n.º 9
0
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:
Exemplo n.º 10
0
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)

Exemplo n.º 11
0
from os.path import join, dirname, abspath
import unittest
from logilab.common import testlib
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_celery'])
linter.global_set_option('required-attributes', ())  # remove required __revision__


def suite():
    return testlib.TestSuite([unittest.makeSuite(test, suiteClass=testlib.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]
    testlib.unittest_main(defaultTest='suite')


Exemplo n.º 12
0
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_flask'])
# remove required __revision__
linter.global_set_option('required-attributes', ())
# We need to ensure that pylint_flask 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)

Exemplo n.º 13
0
import os
import sys
import unittest
from logilab.common import testlib
from pylint.testutils import make_tests, LintTestUsingFile, cb_test_gen, linter
import ConfigParser

HERE = os.path.dirname(os.path.abspath(__file__))
PLUGINPATH = os.path.join(HERE, "..")

linter.prepare_import_path(PLUGINPATH)
linter.load_plugin_modules(['Playero'])
linter.global_set_option('required-attributes', ())  # remove required __revision__
linter.load_file_configuration(os.path.join(HERE, "..", "config", ".pylintrc"))

convs = ['C0111', 'C0103', 'C0301', 'C0303', 'C0304', 'C0321']
warns = ['W0141', 'W0142', 'W0212', 'W0312', 'W0401', 'W0403', 'W0511', 'W0512', 'W0614', 'W0622']
refac = ['R0903', 'R0904', 'R0913']
for disabled in convs + warns + refac:
    linter.disable(disabled)

config = ConfigParser.SafeConfigParser()
config.read(os.path.join(HERE, "..", "config", "playero.cfg"))
PLAYEROPATH = config.get('paths', os.name)
sys.path.append(os.path.join(PLAYEROPATH, "core"))
for scriptdir in ["base", "standard", "extra/StdPy"]:
    for pydir in ['records', 'windows', 'reports', 'routines', 'documents','tools']:
        sys.path.append(os.path.join(PLAYEROPATH, scriptdir, pydir))
sys.path.append(os.path.join(PLUGINPATH, "corepy", "embedded"))

def tests():
Exemplo n.º 14
0
from os.path import join, dirname, abspath
import unittest
from logilab.common import testlib
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 testlib.TestSuite([
        unittest.makeSuite(test, suiteClass=testlib.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]
    testlib.unittest_main(defaultTest='suite')