@@ -41,7 +41,6 @@ def test_settings():
41
41
def test_plugin (workspace ):
42
42
config = FakeConfig ()
43
43
doc = Document (DOC_URI , workspace , DOC_TYPE_ERR )
44
- workspace = None
45
44
plugin .pylsp_settings (config )
46
45
diags = plugin .pylsp_lint (config , workspace , doc , is_saved = False )
47
46
@@ -84,3 +83,40 @@ def test_parse_line_with_context(monkeypatch, word, bounds, workspace):
84
83
assert diag ["message" ] == '"Request" has no attribute "id"'
85
84
assert diag ["range" ]["start" ] == {"line" : 278 , "character" : bounds [0 ]}
86
85
assert diag ["range" ]["end" ] == {"line" : 278 , "character" : bounds [1 ]}
86
+
87
+
88
+ def test_multiple_workspaces (tmpdir ):
89
+ DOC_SOURCE = """
90
+ def foo():
91
+ return
92
+ unreachable = 1
93
+ """
94
+ DOC_ERR_MSG = "Statement is unreachable"
95
+
96
+ # Initialize two workspace folders.
97
+ folder1 = tmpdir .mkdir ("folder1" )
98
+ ws1 = Workspace (uris .from_fs_path (str (folder1 )), Mock ())
99
+ ws1 ._config = Config (ws1 .root_uri , {}, 0 , {})
100
+ folder2 = tmpdir .mkdir ("folder2" )
101
+ ws2 = Workspace (uris .from_fs_path (str (folder2 )), Mock ())
102
+ ws2 ._config = Config (ws2 .root_uri , {}, 0 , {})
103
+
104
+ # Create configuration file for workspace folder 1.
105
+ mypy_config = folder1 .join ("mypy.ini" )
106
+ mypy_config .write ("[mypy]\n warn_unreachable = True" )
107
+
108
+ # Initialize settings for both folders.
109
+ plugin .pylsp_settings (ws1 ._config )
110
+ plugin .pylsp_settings (ws2 ._config )
111
+
112
+ # Test document in workspace 1 (uses mypy.ini configuration).
113
+ doc1 = Document (DOC_URI , ws1 , DOC_SOURCE )
114
+ diags = plugin .pylsp_lint (ws1 ._config , ws1 , doc1 , is_saved = False )
115
+ assert len (diags ) == 1
116
+ diag = diags [0 ]
117
+ assert diag ["message" ] == DOC_ERR_MSG
118
+
119
+ # Test document in workspace 2 (without mypy.ini configuration)
120
+ doc2 = Document (DOC_URI , ws2 , DOC_SOURCE )
121
+ diags = plugin .pylsp_lint (ws2 ._config , ws2 , doc2 , is_saved = False )
122
+ assert len (diags ) == 0
0 commit comments