晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 sh-3ll

HOME


sh-3ll 1.0
DIR:/opt/cloudlinux/venv/lib/python3.11/site-packages/pylint_django/tests/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pylint_django/tests/test_func.py
import csv
import os
import pickle
import sys
from pathlib import Path

import pylint
import pytest

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pylint_django.tests.settings")

HERE = Path(__file__).parent

try:
    # pylint 2.5: test_functional has been moved to pylint.testutils
    from pylint.testutils import FunctionalTestFile, LintModuleTest, lint_module_test

    if "test" not in csv.list_dialects():

        class test_dialect(csv.excel):
            delimiter = ":"
            lineterminator = "\n"

        csv.register_dialect("test", test_dialect)

    lint_module_test.PYLINTRC = HERE / "testing_pylint.rc"
except (ImportError, AttributeError):
    # specify directly the directory containing test_functional.py
    test_functional_dir = os.getenv("PYLINT_TEST_FUNCTIONAL_DIR", "")

    # otherwise look for in in ~/pylint/tests - pylint 2.4
    # this is the pylint git checkout dir, not the pylint module dir
    if not os.path.isdir(test_functional_dir):
        test_functional_dir = os.path.join(os.getenv("HOME", "/home/travis"), "pylint", "tests")

    # or site-packages/pylint/test/ - pylint before 2.4
    if not os.path.isdir(test_functional_dir):
        test_functional_dir = os.path.join(os.path.dirname(pylint.__file__), "test")

    sys.path.append(test_functional_dir)

    from test_functional import FunctionalTestFile, LintModuleTest


sys.path += [str(p.absolute()) for p in (HERE, HERE / "../../", HERE / "input")]


class PylintDjangoLintModuleTest(LintModuleTest):
    """
    Only used so that we can load this plugin into the linter!
    """

    def __init__(self, test_file):
        # if hasattr(test_file, 'option_file') and test_file.option_file is None:
        super(PylintDjangoLintModuleTest, self).__init__(test_file)
        self._linter.load_plugin_modules(["pylint_django"])
        self._linter.load_plugin_configuration()


class PylintDjangoMigrationsTest(PylintDjangoLintModuleTest):
    """
    Only used so that we can load
    pylint_django.checkers.migrations into the linter!
    """

    def __init__(self, test_file):
        super().__init__(test_file)
        self._linter.load_plugin_modules(["pylint_django.checkers.migrations"])
        self._linter.load_plugin_configuration()


def get_tests(input_dir="input", sort=False):
    def _file_name(test):
        return test.base

    input_dir = HERE / input_dir

    suite = []
    for fname in input_dir.iterdir():
        if fname.name != "__init__.py" and fname.name.endswith(".py"):
            suite.append(FunctionalTestFile(str(input_dir.absolute()), str(fname.absolute())))

    # when testing the migrations plugin we need to sort by input file name
    # because the plugin reports the errors in close() which appends them to the
    # report for the last file in the list
    if sort:
        suite.sort(key=_file_name)

    return suite


TESTS = get_tests()
TESTS.extend(get_tests("input/models"))
TESTS_NAMES = [t.base for t in TESTS]


@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
def test_everything(test_file):
    # copied from pylint.tests.test_functional.test_functional
    LintTest = PylintDjangoLintModuleTest(test_file)
    LintTest.setUp()
    LintTest._runTest()


# NOTE: define tests for the migrations checker!
MIGRATIONS_TESTS = get_tests("input/migrations", True)
MIGRATIONS_TESTS_NAMES = [t.base for t in MIGRATIONS_TESTS]


@pytest.mark.parametrize("test_file", MIGRATIONS_TESTS, ids=MIGRATIONS_TESTS_NAMES)
def test_migrations_plugin(test_file):
    LintTest = PylintDjangoMigrationsTest(test_file)
    LintTest.setUp()
    LintTest._runTest()


@pytest.mark.parametrize("test_file", MIGRATIONS_TESTS[:1], ids=MIGRATIONS_TESTS_NAMES[:1])
def test_linter_should_be_pickleable_with_pylint_django_plugin_installed(test_file):
    LintTest = PylintDjangoMigrationsTest(test_file)
    LintTest.setUp()

    # LintModuleTest sets reporter to instance of FunctionalTestReporter that is not picklable
    LintTest._linter.reporter = None
    pickle.dumps(LintTest._linter)


if __name__ == "__main__":
    sys.exit(pytest.main(sys.argv))