3434 'name' : 'python_package' ,
3535 'description' : 'Package with python code' ,
3636 },
37+ {
38+ 'name' : 'msg_package' ,
39+ 'description' : 'Package with only msg files' ,
40+ 'has_msg' : True ,
41+ 'has_python' : False ,
42+ },
3743 {
3844 'name' : 'python_package_symlink' ,
3945 'description' : 'Package with python code, installed with symlink in build' ,
6470 'description' : 'Package with python code' ,
6571 'scripts_destination' : 'lib/python_package_with_scripts' ,
6672 },
67- {
68- 'name' : 'msg_package' ,
69- 'description' : 'Package with only msg files' ,
70- 'has_msg' : True ,
71- 'has_python' : False ,
72- },
7373]
7474
7575
@@ -80,9 +80,25 @@ def test_from_template():
8080 packages_dir = PWD / 'packages'
8181 shutil .rmtree (packages_dir , ignore_errors = True )
8282
83- # Create test packages from template
84- template_dir = SOURCE_DIR / 'test' / 'pkg_template'
83+ # extend the tests to include combinations of msg and python
84+ additional_options = TESTS_OPTIONS . copy ()
8585 for options in TESTS_OPTIONS :
86+ if options ['name' ].startswith ('python_package' ):
87+ msg_options = options .copy ()
88+ msg_options ['name' ] += '_with_msg'
89+ msg_options ['description' ] += 'and msg files'
90+ msg_options ['has_msg' ] = True
91+ additional_options .append (msg_options )
92+ elif options ['name' ].startswith ('msg_package' ):
93+ py_options = options .copy ()
94+ py_options ['name' ] += '_with_python_before'
95+ py_options ['description' ] += ' and python code before msg'
96+ py_options ['has_python_before' ] = True
97+ additional_options .append (py_options )
98+
99+ template_dir = SOURCE_DIR / 'test' / 'pkg_template'
100+ # Create test packages from template
101+ for options in additional_options :
86102 options = DEFAULT_OPTIONS | options
87103 print (f"Generating package { options ['name' ]} " )
88104 print (f" options: { options } " )
@@ -96,7 +112,7 @@ def test_from_template():
96112 if options ['has_msg' ]:
97113 shutil .copytree (template_dir / 'msg' , package_dir / 'msg' )
98114
99- if options ['has_python' ]:
115+ if options ['has_python' ] or options [ 'has_python_before' ] :
100116 ignore_patterns = shutil .ignore_patterns ('*.jinja' )
101117 shutil .copytree (template_dir / 'package_directory' , package_dir / package_subdir , ignore = ignore_patterns )
102118 template = Template (Path .read_text (template_dir / 'package_directory' / '__init__.py.jinja' ))
@@ -161,7 +177,7 @@ def do_test_package(package_name, options):
161177 assert install_path .exists (), f"install path does not exist for { package_name } : { install_path } "
162178 assert (install_path / '__init__.py' ).exists (), f"missing __init__.py in { install_path } "
163179
164- if options ['has_python' ]:
180+ if options ['has_python' ] or options [ 'has_python_before' ] :
165181 assert Path .read_text (install_path / '__init__.py' ).startswith (f"# This is { package_name } " ), \
166182 f"__init__.py should be from { package_name } python package"
167183
0 commit comments