From: Douglas Bagnall Date: Thu, 7 Sep 2023 03:27:21 +0000 (+1200) Subject: pytest: sddl strings dir can be defined in class X-Git-Tag: tevent-0.16.0~452 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a4fc3fedf46faa78063de3de6841936cc24720e;p=thirdparty%2Fsamba.git pytest: sddl strings dir can be defined in class Before we had to do this in an environment variable. In that case we are probably wanting to monitor changes, so we like it to print more messages than we want to see in an autobuild run that will hopefully never do anything interesting. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/sddl.py b/python/samba/tests/sddl.py index 8cc3ac9844c..cb3038ad16f 100644 --- a/python/samba/tests/sddl.py +++ b/python/samba/tests/sddl.py @@ -31,6 +31,10 @@ class SddlDecodeEncodeBase(TestCase): def setUpDynamicTestCases(cls): cls.domain_sid = security.dom_sid("S-1-2-3-4") + strings_dir = getattr(cls, 'strings_dir', None) + if strings_dir is not None: + cls.read_windows_strings(strings_dir, False) + for (key, fn) in [ ("SAMBA_WRITE_WINDOWS_STRINGS_DIR", cls.write_windows_strings), @@ -136,7 +140,7 @@ class SddlDecodeEncodeBase(TestCase): print(f"{p[0]} -> {p[1]}", file=f) @classmethod - def read_windows_strings(cls, dir): + def read_windows_strings(cls, dir, verbose=True): """This is complementary to cls.write_windows_strings(), which writes these tests in a format usable on Windows. In this case examples will be read in, replacing the strings here with the @@ -170,17 +174,19 @@ class SddlDecodeEncodeBase(TestCase): new_pairs.add((o, c)) if old_pairs == new_pairs: - print(f"no change in {c_GREEN(cls.name)}") # nothing to do + if verbose: + print(f"no change in {c_GREEN(cls.name)}") return - print(f"change in {c_RED(cls.name)}") - print("added:") - for x in sorted(new_pairs - old_pairs): - print(x) - print("removed:") - for x in sorted(old_pairs - new_pairs): - print(x) + if verbose: + print(f"change in {c_RED(cls.name)}") + print("added:") + for x in sorted(new_pairs - old_pairs): + print(x) + print("removed:") + for x in sorted(old_pairs - new_pairs): + print(x) cls.strings[:] = sorted(new_pairs)