From 0e72e8fac81f03953901f9c7e074637f706aab0a Mon Sep 17 00:00:00 2001 From: Seth Morton Date: Thu, 7 Nov 2019 19:44:14 -0800 Subject: Add tests for new public method --- tests/test_regex.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/test_regex.py b/tests/test_regex.py index d3fe617..a6da62d 100644 --- a/tests/test_regex.py +++ b/tests/test_regex.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import pytest +from natsort import ns, numeric_regex_chooser from natsort.utils import NumericalRegularExpressions as NumRegex @@ -98,3 +99,22 @@ labels = ["{}-{}".format(given, regex_names[regex]) for given, _, regex in regex def test_regex_splits_correctly(x, expected, regex): # noinspection PyUnresolvedReferences assert regex.split(x) == expected + + +@pytest.mark.parametrize( + "given, expected", + [ + (ns.INT, NumRegex.int_nosign()), + (ns.INT | ns.UNSIGNED, NumRegex.int_nosign()), + (ns.INT | ns.SIGNED, NumRegex.int_sign()), + (ns.INT | ns.NOEXP, NumRegex.int_nosign()), + (ns.FLOAT, NumRegex.float_nosign_exp()), + (ns.FLOAT | ns.UNSIGNED, NumRegex.float_nosign_exp()), + (ns.FLOAT | ns.SIGNED, NumRegex.float_sign_exp()), + (ns.FLOAT | ns.NOEXP, NumRegex.float_nosign_noexp()), + (ns.FLOAT | ns.SIGNED | ns.NOEXP, NumRegex.float_sign_noexp()), + (ns.FLOAT | ns.UNSIGNED | ns.NOEXP, NumRegex.float_nosign_noexp()), + ], +) +def test_regex_chooser(given, expected): + assert numeric_regex_chooser(given) == expected.pattern[1:-1] # remove parens -- cgit v1.2.1