Skip to content

Commit 739dfcb

Browse files
authored
Unit test friendly folder structure for Python examples (#237)
1 parent c9f936d commit 739dfcb

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

example_python/generate_parameter_module_example/__init__.py

Whitespace-only changes.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
import generate_parameter_module_example
3+
4+
print(f'Imported module from: {generate_parameter_module_example.__file__}')
5+
6+
import generate_parameter_module_example.admittance_parameters # noqa: E402
7+
8+
print('Imported generated parameter module')
9+
10+
import generate_parameter_module_example.minimal_publisher # noqa: E402
11+
12+
print('Imported minimal publisher module')

generate_parameter_library_py/generate_parameter_library_py/generate_python_module.py

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def run(output_file, yaml_file, validation_module=''):
4848
with open(output_file, 'w') as f:
4949
f.write(code)
5050

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

5256
def parse_args():
5357
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)