Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test friendly folder structure for Python examples #237

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
12 changes: 12 additions & 0 deletions example_python/test/test_load_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
import generate_parameter_module_example

print(f'Imported module from: {generate_parameter_module_example.__file__}')

import generate_parameter_module_example.admittance_parameters # noqa: E402

print('Imported generated parameter module')

import generate_parameter_module_example.minimal_publisher # noqa: E402

print('Imported minimal publisher module')
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def run(output_file, yaml_file, validation_module=''):
with open(output_file, 'w') as f:
f.write(code)

# Put an __init__.py file if one does not yet exist.
init_file = os.path.join(os.path.dirname(output_file), '__init__.py')
open(init_file, 'a').close()


def parse_args():
parser = argparse.ArgumentParser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def generate_parameter_module(module_name, yaml_file, validation_module=''):
install_dir = os.path.join(
colcon_ws,
'install',
pkg_name,
Copy link
Collaborator Author

@sea-bass sea-bass Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be fixed in #236, but needed for this PR to work properly

'lib',
py_version,
'site-packages',
Expand Down
Loading