コード例 #1
0
def test_basic(workspace, config):
    doc = Document(uris.from_fs_path(str(data / "file.py")), workspace)
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("foo", (7, 4), (7, 7), "deprecated at some point"),
        build_diagnostic("imported", (9, 0), (9, 8), "test reason"),
    ]
コード例 #2
0
def test_recursive(workspace, config, document):
    doc = document("""
from testpackage import bar

bar()
""")
    update_setting(config, "recursive", True)
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("bar", (3, 0), (3, 3), "nested"),
    ]
コード例 #3
0
def test_cache_dir(workspace, config, document):
    doc = document("""
from cachetest import bar

bar()
""")
    update_setting(config, "additional_search_paths", [str(data)])
    update_setting(config, "cache_dir", str(data / "cache"))
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("bar", (3, 0), (3, 3), "cached"),
    ]
コード例 #4
0
def test_search_paths(workspace, config, document):
    doc = document("""
from bar import bar

bar()
""")
    update_setting(config, "additional_search_paths",
                   [str(data / "testpackage")])
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("bar", (3, 0), (3, 3), "nested"),
    ]
コード例 #5
0
def test_empty_reason(workspace, config, document):
    doc = document("""
import deprecated

@deprecated.deprecated
def foo():
    pass

foo()
""")
    update_setting(config, "reason_keyword", "excuse")
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("foo", (7, 0), (7, 3), None),
    ]
コード例 #6
0
def test_decorator_name(workspace, config, document):
    doc = document("""
import bogus

@bogus.deprecateme("nope")
def foo():
    pass

foo()
""")
    update_setting(config, "decorator_module", "bogus")
    update_setting(config, "decorator_function", "deprecateme")
    diagnostics = pyls_lint(config, doc)

    assert diagnostics == [
        build_diagnostic("foo", (7, 0), (7, 3), "nope"),
    ]