Skip to content

Commit d84b908

Browse files
committed
temp fix for passing tests: rearranging file_include
1 parent bb15e83 commit d84b908

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

bindings/python/tests/test_generate.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ def generate_bindings(cpp_code_block, module_name, tmp_path):
4848
parsed_info = test_parse.get_parsed_info(
4949
tmp_path=tmp_path, file_contents=cpp_code_block
5050
)
51+
52+
file_include = "pcl" + parsed_info["name"].rsplit("pcl")[-1]
53+
5154
# Get the binded code
5255
binded_code = generate.generate(module_name=module_name, parsed_info=parsed_info)
5356
# List to string
5457
binded_code = "".join(binded_code)
5558

56-
return remove_whitespace(binded_code)
59+
return f"#include<{file_include}>", remove_whitespace(binded_code)
5760

5861

59-
def get_expected_string(expected_module_code):
62+
def get_expected_string(file_include, expected_module_code):
6063
"""
6164
Returns expected output string after combining inclusions and pybind11's initial lines.
6265
@@ -67,7 +70,7 @@ def get_expected_string(expected_module_code):
6770
- expected_output (str): The stripped off, combined code.
6871
"""
6972

70-
file_include = "#include <file.cpp>"
73+
# file_include = "#include <file.cpp>"
7174

7275
# Get pybind11's intial lines in the form of a string
7376
initial_pybind_lines = "".join(generate.bind._initial_pybind_lines)
@@ -81,7 +84,7 @@ def get_expected_string(expected_module_code):
8184

8285
def test_struct_without_members(tmp_path):
8386
cpp_code_block = "struct AStruct {};"
84-
output = generate_bindings(
87+
file_include, output = generate_bindings(
8588
tmp_path=tmp_path, cpp_code_block=cpp_code_block, module_name="pcl"
8689
)
8790

@@ -92,7 +95,9 @@ def test_struct_without_members(tmp_path):
9295
}
9396
"""
9497

95-
assert output == get_expected_string(expected_module_code=expected_module_code)
98+
assert output == get_expected_string(
99+
file_include=file_include, expected_module_code=expected_module_code
100+
)
96101

97102

98103
def test_struct_with_members(tmp_path):
@@ -101,7 +106,7 @@ def test_struct_with_members(tmp_path):
101106
int aMember;
102107
};
103108
"""
104-
output = generate_bindings(
109+
file_include, output = generate_bindings(
105110
tmp_path=tmp_path, cpp_code_block=cpp_code_block, module_name="pcl"
106111
)
107112

@@ -113,4 +118,6 @@ def test_struct_with_members(tmp_path):
113118
}
114119
"""
115120

116-
assert output == get_expected_string(expected_module_code=expected_module_code)
121+
assert output == get_expected_string(
122+
file_include=file_include, expected_module_code=expected_module_code
123+
)

0 commit comments

Comments
 (0)