Skip to content

Commit 2f34836

Browse files
committed
[ty] Add test capturing redundant re-exports from pandas
This roughly mimics how pandas defines and re-exports `read_csv` at the top-level module.
1 parent db9eee7 commit 2f34836

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

crates/ty_ide/src/all_symbols.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,86 @@ mod tests {
222222
SubDiagnosticSeverity,
223223
};
224224

225+
/// Tests that we merge redundant re-exports in a real world use case.
226+
///
227+
/// This mimics how pandas exports `read_csv` in its top-level module
228+
/// but where it is actually defined in a deeper module. Note though
229+
/// that we use `zqzqzq` instead of `read_csv` to make our fuzzy query
230+
/// return only exactly what we care about.
231+
#[test]
232+
fn pandas_read_csv_merged() {
233+
let test = CursorTest::builder()
234+
.source("main.py", "<CURSOR>")
235+
.source(
236+
"pandas/__init__.py",
237+
"
238+
from pandas.io.api import zqzqzq
239+
__all__ = ['zqzqzq']
240+
",
241+
)
242+
.source("pandas/io/__init__.py", "")
243+
.source(
244+
"pandas/io/api.py",
245+
"
246+
from pandas.io.parsers import zqzqzq
247+
__all__ = ['zqzqzq']
248+
",
249+
)
250+
.source(
251+
"pandas/io/parsers/__init__.py",
252+
"
253+
from pandas.io.parsers.readers import zqzqzq
254+
__all__ = ['zqzqzq']
255+
",
256+
)
257+
.source(
258+
"pandas/io/parsers/readers.py",
259+
"
260+
def zqzqzq():
261+
pass
262+
",
263+
)
264+
.build();
265+
266+
assert_snapshot!(test.all_symbols("zqzqzq"), @r"
267+
info[all-symbols]: AllSymbolInfo
268+
--> pandas/__init__.py:2:27
269+
|
270+
2 | from pandas.io.api import zqzqzq
271+
| ^^^^^^
272+
3 | __all__ = ['zqzqzq']
273+
|
274+
info: Variable zqzqzq
275+
276+
info[all-symbols]: AllSymbolInfo
277+
--> pandas/io/api.py:2:31
278+
|
279+
2 | from pandas.io.parsers import zqzqzq
280+
| ^^^^^^
281+
3 | __all__ = ['zqzqzq']
282+
|
283+
info: Variable zqzqzq
284+
285+
info[all-symbols]: AllSymbolInfo
286+
--> pandas/io/parsers/__init__.py:2:39
287+
|
288+
2 | from pandas.io.parsers.readers import zqzqzq
289+
| ^^^^^^
290+
3 | __all__ = ['zqzqzq']
291+
|
292+
info: Variable zqzqzq
293+
294+
info[all-symbols]: AllSymbolInfo
295+
--> pandas/io/parsers/readers.py:2:5
296+
|
297+
2 | def zqzqzq():
298+
| ^^^^^^
299+
3 | pass
300+
|
301+
info: Function zqzqzq
302+
");
303+
}
304+
225305
#[test]
226306
fn all_symbols_multi_file() {
227307
// We use odd symbol names here so that we can

0 commit comments

Comments
 (0)