Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased

- Fix `--regex-pattern` being ignored by the CLI.
- Support Python 3.14.
- Drop support for Python 3.9 and lower.
- Use tox for local test runs and in CI.
Expand Down
1 change: 1 addition & 0 deletions slugify/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def slugify_params(args: argparse.Namespace) -> dict[str, Any]:
save_order=args.save_order,
separator=args.separator,
stopwords=args.stopwords,
regex_pattern=args.regex_pattern,
lowercase=args.lowercase,
replacements=args.replacements,
allow_unicode=args.allow_unicode
Expand Down
9 changes: 8 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ class TestCommandParams(unittest.TestCase):
'separator': '-',
'stopwords': None,
'lowercase': True,
'replacements': None
'replacements': None,
'regex_pattern': None
}

def get_params_from_cli(self, *argv):
Expand Down Expand Up @@ -623,6 +624,12 @@ def test_replacements_wrong(self):
self.assertEqual(err.exception.code, 2)
self.assertIn("Replacements must be of the form: ORIGINAL->REPLACED", cse.getvalue())

def test_regex_pattern(self):
params = self.get_params_from_cli('--regex-pattern', '[^-a-z0-9_]+', '___This is a test___')
expected = self.make_params(text='___This is a test___', regex_pattern='[^-a-z0-9_]+')
self.assertParamsMatch(expected, params)
self.assertEqual(slugify(**params), '___this-is-a-test___')

def test_text_in_cli(self):
params = self.get_params_from_cli('Cool Text')
expected = self.make_params(text='Cool Text')
Expand Down