Skip to content

Commit d4beec3

Browse files
committed
test(python): local classes are extracted defs now (DeusData#1548)
pylsp_nested_and_local_classbody_calls_join_extracted_caller asserted that a class declared in a function body is NOT a def, which is the behaviour DeusData#1548 fixes. Their class-body calls still join the enclosing function; that part is unchanged. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 5bfa7b5 commit d4beec3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎tests/test_py_lsp.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,12 +3629,16 @@ TEST(pylsp_nested_and_local_classbody_calls_join_extracted_caller) {
36293629
{"field(35)", "test.main.Controller.build", "test.main.field"},
36303630
};
36313631
CBMFileResult *r = extract_py(source);
3632-
bool correct = pylsp_class_sites(r, source, sites, 7) &&
3633-
!pylsp_module_has_def(r, "test.main.build.Local") &&
3634-
!pylsp_module_has_def(r, "test.main.Controller.build.Local");
3632+
/* #1548: a class declared in a function body is extracted, as a local of
3633+
* that function; its class-body calls still join the enclosing function
3634+
* (the sites above), never the local class. */
3635+
bool sites_ok = pylsp_class_sites(r, source, sites, 7);
3636+
bool locals_extracted = r && pylsp_module_has_def(r, "test.main.build.Local") &&
3637+
pylsp_module_has_def(r, "test.main.Controller.build.Local");
36353638
if (r)
36363639
cbm_free_result(r);
3637-
ASSERT_TRUE(correct);
3640+
ASSERT_TRUE(sites_ok);
3641+
ASSERT_TRUE(locals_extracted);
36383642
PASS();
36393643
}
36403644

0 commit comments

Comments
 (0)