From 664653b8d14cbe21c954d248b2bb5ef0d2d60043 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 17 Aug 2022 11:50:55 +1200 Subject: [PATCH] pytest/samba-tool visualize: test '--color' aliases By convention, 'tty' is a common alias for 'auto', 'always' and 'force' mean 'yes', and 'never' means no. It seems 'never; and 'always' are more common than 'yes' and 'no'. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett Reviewed-by: Joseph Sutton --- python/samba/tests/samba_tool/visualize.py | 24 +++++++++++++++++----- selftest/knownfail.d/samba-tool-visualize | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 selftest/knownfail.d/samba-tool-visualize diff --git a/python/samba/tests/samba_tool/visualize.py b/python/samba/tests/samba_tool/visualize.py index b4385d0b716..f4323725b75 100644 --- a/python/samba/tests/samba_tool/visualize.py +++ b/python/samba/tests/samba_tool/visualize.py @@ -170,13 +170,27 @@ class SambaToolVisualizeLdif(SambaToolCmdTest): # NO_COLOR='no': we still expect no colour ['no', '--color=auto', False], # NO_COLOR=' ', alias for 'auto' + [' ', '--color=tty', False], + # NO_COLOR=' ', alias for 'auto' + [' ', '--color=if-tty', False], + # NO_COLOR='', alias for 'auto' + ['', '--color=tty', True], + # NO_COLOR='', alias for 'no' + ['', '--color=never', False], + # NO_COLOR='x', alias for 'yes' (--color=yes wins) + ['x', '--color=force', True], ]: os.environ['NO_COLOR'] = env - print(f" {env}, {opt}, {is_colour}") - result, out, err = self.runsubcmd("visualize", "ntdsconn", - '-H', self.dburl, - '-S', - opt) + + try: + result, out, err = self.runsubcmd("visualize", "ntdsconn", + '-H', self.dburl, + '-S', + opt) + except SystemExit as e: + # optparse makes us do this + self.fail(f"optparse rejects {env}, {opt}, {is_colour}") + self.assertCmdSuccess(result, out, err) self.assert_colour(out, is_colour, monochrome) diff --git a/selftest/knownfail.d/samba-tool-visualize b/selftest/knownfail.d/samba-tool-visualize new file mode 100644 index 00000000000..e92dd83a8fb --- /dev/null +++ b/selftest/knownfail.d/samba-tool-visualize @@ -0,0 +1 @@ +samba.tests.samba_tool.visualize.samba.tests.samba_tool.visualize.SambaToolVisualizeLdif.test_colour_auto_tty -- 2.47.3