From: Michael R. Crusoe <crusoe@debian.org>
Subject: Make a test more flexible
Forwarded: https://github.com/gem-pasteur/macsyfinder/pull/77

When testing during packaging for Debian, {bin_name} is quite wide
("python3.12 -m unittest") causing `[--defaults]` to flow to the next line.
--- macsyfinder.orig/tests/test_macsyconfig.py
+++ macsyfinder/tests/test_macsyconfig.py
@@ -23,6 +23,7 @@
 ##########################################################################
 import argparse
 import os.path
+import re
 import io
 import sys
 import tempfile
@@ -598,9 +599,9 @@
             # if the tests are ran from cmd line python tests/run_tes.py ... the bin name is run_test.py
             # if the tests are ran from setup python setup.py test the bin name is setup.py
             bin_name = os.path.split(sys.argv[0])[-1]
-            self.assertEqual(stderr,
-                             f"""usage: {bin_name} [-h] [--no-color | --white-bg | --dark-bg] [--defaults]
-{bin_name}: error: argument --dark-bg: not allowed with argument --white-bg""")
+            self.assertTrue(re.match(
+                             re.escape(f"usage: {bin_name} [-h] [--no-color | --white-bg | --dark-bg]") + r"\s+" + re.escape(f"""[--defaults]
+{bin_name}: error: argument --dark-bg: not allowed with argument --white-bg"""), stderr))
 
         finally:
             argparse._sys.exit = real_sys_exit
