summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-08-17 11:50:55 +1200
committerDouglas Bagnall <dbagnall@samba.org>2022-09-06 21:12:36 +0000
commit664653b8d14cbe21c954d248b2bb5ef0d2d60043 (patch)
tree05a94e19e312a75dd2bac2c9a7bba862b8004122 /python
parent6160e956b5931a2cbeb98e042c2fe71981115ba0 (diff)
downloadsamba-664653b8d14cbe21c954d248b2bb5ef0d2d60043.tar.gz
samba-664653b8d14cbe21c954d248b2bb5ef0d2d60043.tar.bz2
samba-664653b8d14cbe21c954d248b2bb5ef0d2d60043.zip
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 <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/samba_tool/visualize.py24
1 files changed, 19 insertions, 5 deletions
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)