8000 Merge utils: adjusts aa-notify tests to handle Python 3.13+ · DreamConnected/libapparmor-dev@5f8c2c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f8c2c5

Browse files
committed
Merge utils: adjusts aa-notify tests to handle Python 3.13+
Python 3.13 changes the formatting of long-short option pairs that use a meta-variable. Up until 3.13 the meta-variable was repeated. Since Python change [1] the meta-var is only printed once. [1] python/cpython#103372 Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com> MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1495 Approved-by: Georgia Garcia <georgia.garcia@canonical.com> Approved-by: Christian Boltz <apparmor@cboltz.de> Merged-by: Zygmunt Krynicki <me@zygoon.pl> (cherry picked from commit 219626c)
2 parents b04faf1 + ee2dc1b commit 5f8c2c5

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

utils/test/test-aa-notify.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,13 @@ def test_help_contents(self):
209209
-p, --poll poll AppArmor logs and display notifications
210210
--display DISPLAY set the DISPLAY environment variable (might be needed if
211211
sudo resets $DISPLAY)
212-
-f FILE, --file FILE search FILE for AppArmor messages
212+
-f, --file FILE search FILE for AppArmor messages
213213
-l, --since-last display stats since last login
214-
-s NUM, --since-days NUM
215-
show stats for last NUM days (can be used alone or with
214+
-s, --since-days NUM show stats for last NUM days (can be used alone or with
216215
-p)
217216
-v, --verbose show messages with stats
218-
-u USER, --user USER user to drop privileges to when not using sudo
219-
-w NUM, --wait NUM wait NUM seconds before displaying notifications (with
217+
-u, --user USER user to drop privileges to when not using sudo
218+
-w, --wait NUM wait NUM seconds before displaying notifications (with
220219
-p)
221220
--prompt-filter PF kind of operations which display a popup prompt
222221
--debug debug mode
@@ -238,6 +237,28 @@ def test_help_contents(self):
238237
regular expression to match the network socket type
239238
''' # noqa: E128
240239

240+
if sys.version_info[:2] < (3, 13):
241+
# Python 3.13 tweaked argparse output [1]. When running on older
242+
# Python versions, we adapt the expected output to match.
243+
#
244+
# https://github.com/python/cpython/pull/103372
245+
patches = [(
246+
', --file FILE ',
247+
' FILE, --file FILE',
248+
), (
249+
', --since-days NUM show stats for last NUM days (can be used alone or with',
250+
' NUM, --since-days NUM\n'
251+
+ ' show stats for last NUM days (can be used alone or with',
252+
), (
253+
', --user USER ',
254+
' USER, --user USER',
255+
), (
256+
', --wait NUM ',
257+
' NUM, --wait NUM&# 607A 39;,
258+
)]
259+
for patch in patches:
260+
expected_output_2 = expected_output_2.replace(patch[0], patch[1])
261+
241262
return_code, output = cmd(aanotify_bin + ['--help'])
242263
result = 'Got return code {}, expected {}\n'.format(return_code, expected_return_code)
243264
self.assertEqual(expected_return_code, return_code, result + output)

0 commit comments

Comments
 (0)
0