From 664653b8d14cbe21c954d248b2bb5ef0d2d60043 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Wed, 17 Aug 2022 11:50:55 +1200 Subject: 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 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'python/samba') 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) -- cgit v1.2.3