Skip to content

Commit

Permalink
Merge pull request #77 from mr-c/flexi_match
Browse files Browse the repository at this point in the history
Make a test more flexible
  • Loading branch information
bneron authored Oct 3, 2024
2 parents 6f745bd + b193370 commit f7b1a97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ This is a list of people who have made contributions to Macsyfinder.
* Nilesh Patra <https://github.com/nileshpatra> :bug: :computer:
* Antônio Camargo <https://github.com/apcamargo> :bug:
* TrellixVulnTeam <https://github.com/TrellixVulnTeam> :computer:
* Michael R. Crusoe <https://github.com/mr-c> :white_check_mark:
28 changes: 19 additions & 9 deletions tests/test_macsyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
# If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
import argparse
import os.path
import io
import os.path
import re
import shutil
import sys
import tempfile
import shutil
from unittest.mock import patch

from tests import MacsyTest

import macsypy.scripts.macsyconfig as msf_cfg
from macsypy import __version__ as msf_vers
from macsypy.config import MacsyDefaults, Config
from macsypy.config import Config, MacsyDefaults
from macsypy.error import MacsypyError
import macsypy.scripts.macsyconfig as msf_cfg
from tests import MacsyTest


class TestConfigParserWithComment(MacsyTest):
Expand Down Expand Up @@ -598,9 +598,19 @@ def test_parse_args(self):
# 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
Expand Down

0 comments on commit f7b1a97

Please sign in to comment.