File tree Expand file tree Collapse file tree 6 files changed +41
-12
lines changed
test/unit_tests/test_generators/test_debian Expand file tree Collapse file tree 6 files changed +41
-12
lines changed Original file line number Diff line number Diff line change 1212 uses : ros-infrastructure/ci/.github/workflows/pytest.yaml@main
1313 with :
1414 matrix-filter : del(.matrix.os[] | select(contains("windows")))
15+
16+ # Dedicated job for testing with empy < 4
17+ pytest-empy-legacy :
18+ runs-on : ubuntu-latest
19+ name : Test empy < 4 compatibility
20+ steps :
21+ - uses : actions/checkout@v4
22+ - name : Set up Python
23+ uses : actions/setup-python@v4
24+ - name : Install dependencies with empy < 4
25+ run : |
26+ python -m pip install --upgrade pip
27+ pip install -e .[test] 'empy<4'
28+ - name : Run tests
29+ run : |
30+ python -m pytest test/ -v
1531 yamllint :
1632 runs-on : ubuntu-latest
1733 steps :
Original file line number Diff line number Diff line change 7878from bloom .logging import is_debug
7979from bloom .logging import warning
8080
81+ from bloom .util import expand_template_em
82+
8183from bloom .commands .git .patch .common import get_patch_config
8284from bloom .commands .git .patch .common import set_patch_config
8385
@@ -534,7 +536,7 @@ def __process_template_folder(path, subs):
534536 info ("Expanding '{0}' -> '{1}'" .format (
535537 os .path .relpath (item ),
536538 os .path .relpath (template_path )))
537- result = em . expand (template , ** subs )
539+ result = expand_template_em (template , subs )
538540 # Don't write an empty file
539541 if len (result ) == 0 and \
540542 os .path .basename (template_path ) in ['copyright' ]:
Original file line number Diff line number Diff line change 8181
8282from bloom .util import code
8383from bloom .util import execute_command
84+ from bloom .util import expand_template_em
8485from bloom .util import maybe_continue
8586
8687try :
8990 debug (traceback .format_exc ())
9091 error ("rosdistro was not detected, please install it." , exit = True )
9192
92- try :
93- import em
94- except ImportError :
95- debug (traceback .format_exc ())
96- error ("empy was not detected, please install it." , exit = True )
97-
9893# Drop the first log prefix for this command
9994enable_drop_first_log_prefix (True )
10095
@@ -379,7 +374,7 @@ def __process_template_folder(path, subs):
379374 info ("Expanding '{0}' -> '{1}'" .format (
380375 os .path .relpath (item ),
381376 os .path .relpath (template_path )))
382- result = em . expand (template , ** subs )
377+ result = expand_template_em (template , subs )
383378 # Write the result
384379 with io .open (template_path , 'w' , encoding = 'utf-8' ) as f :
385380 if sys .version_info .major == 2 :
Original file line number Diff line number Diff line change 8484 to_unicode = str
8585
8686
87+ def expand_template_em (template , subs ):
88+ """
89+ Compatibility function for EmPy 3 and 4.
90+ EmPy 3: em.expand(template, **kwargs)
91+ EmPy 4: em.expand(template, locals=dict)
92+ """
93+ try :
94+ import em
95+ except ImportError :
96+ error ("empy was not detected, please install it." , exit = True )
97+
98+ if em .__version__ .startswith ('3' ):
99+ return em .expand (template , ** subs )
100+ else :
101+ return em .expand (template , locals = subs )
102+
103+
87104def flush_stdin ():
88105 try :
89106 from termios import tcflush , TCIFLUSH
Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3- import sys
43from setuptools import find_packages , setup
54
65
2019 install_requires = [
2120 'catkin_pkg >= 0.4.3' ,
2221 'setuptools < 82' ,
23- 'empy < 4 ' ,
22+ 'empy' ,
2423 'packaging' ,
2524 'python-dateutil' ,
2625 'PyYAML' ,
Original file line number Diff line number Diff line change 22
33from ....utils .common import redirected_stdio
44
5- from bloom .generators .debian .generator import em
65from bloom .generators .debian .generator import get_changelogs
76from bloom .generators .debian .generator import format_description
7+ from bloom .util import expand_template_em
88
99from catkin_pkg .packages import find_packages
1010
@@ -24,7 +24,7 @@ def test_unicode_templating():
2424 assert 'bad_changelog_pkg' in packages
2525 chlogs = get_changelogs (packages ['bad_changelog_pkg' ])
2626 template = "@(changelog)"
27- em . expand (template , {'changelog' : chlogs [0 ][2 ]})
27+ expand_template_em (template , {'changelog' : chlogs [0 ][2 ]})
2828
2929
3030def test_format_description ():
You can’t perform that action at this time.
0 commit comments