]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytest/samba-tool visualize: test '--color' aliases
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 16 Aug 2022 23:50:55 +0000 (11:50 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Tue, 6 Sep 2022 21:12:36 +0000 (21:12 +0000)
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>
python/samba/tests/samba_tool/visualize.py
selftest/knownfail.d/samba-tool-visualize [new file with mode: 0644]

index b4385d0b7164a248d941e986226572c75325565b..f4323725b755325743203b15a13fcf33baeaef6e 100644 (file)
@@ -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 (file)
index 0000000..e92dd83
--- /dev/null
@@ -0,0 +1 @@
+samba.tests.samba_tool.visualize.samba.tests.samba_tool.visualize.SambaToolVisualizeLdif.test_colour_auto_tty