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"), ]
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"), ]
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"), ]
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"), ]
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), ]
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"), ]