diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2020-11-19 21:24:12 -0800 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2020-11-19 21:27:52 -0800 |
commit | 7171f51f86f3d34cb17998c4568783f08577eb73 (patch) | |
tree | d437dcce0310e97c5209bb266dfd7a8783c295be | |
parent | d5ab4ffdc2aa8b84dc887f01ba6704ef71c13363 (diff) | |
download | natsort-7171f51f86f3d34cb17998c4568783f08577eb73.tar.gz |
Test that checks unicode number presence won't crater tests
Instead of failing, it only raises a warning.
-rw-r--r-- | tests/test_unicode_numbers.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/tests/test_unicode_numbers.py b/tests/test_unicode_numbers.py index a8ee3c7..78a67f4 100644 --- a/tests/test_unicode_numbers.py +++ b/tests/test_unicode_numbers.py @@ -4,6 +4,7 @@ Test the Unicode numbers module. """ import unicodedata +import warnings from natsort.unicode_numbers import ( decimal_chars, @@ -34,11 +35,21 @@ def test_decimal_chars_contains_only_valid_unicode_decimal_characters(): def test_numeric_chars_contains_all_valid_unicode_numeric_and_digit_characters(): - set_numeric_hex = set(numeric_hex) set_numeric_chars = set(numeric_chars) set_digit_chars = set(digit_chars) set_decimal_chars = set(decimal_chars) - for i in range(0X110000): + + assert set_decimal_chars.isdisjoint(digits_no_decimals) + assert set_digit_chars.issuperset(digits_no_decimals) + + assert set_decimal_chars.isdisjoint(numeric_no_decimals) + assert set_numeric_chars.issuperset(numeric_no_decimals) + + +def test_missing_unicode_number_in_collection(): + ok = True + set_numeric_hex = set(numeric_hex) + for i in range(0x110000): try: a = chr(i) except ValueError: @@ -46,20 +57,16 @@ def test_numeric_chars_contains_all_valid_unicode_numeric_and_digit_characters() if a in "0123456789": continue if unicodedata.numeric(a, None) is not None: - assert i in set_numeric_hex - assert a in set_numeric_chars - if unicodedata.digit(a, None) is not None: - assert i in set_numeric_hex - assert a in set_digit_chars - if unicodedata.decimal(a, None) is not None: - assert i in set_numeric_hex - assert a in set_decimal_chars - - assert set_decimal_chars.isdisjoint(digits_no_decimals) - assert set_digit_chars.issuperset(digits_no_decimals) - - assert set_decimal_chars.isdisjoint(numeric_no_decimals) - assert set_numeric_chars.issuperset(numeric_no_decimals) + if i not in set_numeric_hex: + ok = False + if not ok: + warnings.warn( + """\ +Not all numeric unicode characters are represented in natsort/unicode_numeric_hex.py +This can be addressed by running dev/generate_new_unicode_numbers.py with the current \ +version of Python. +""" + ) def test_combined_string_contains_all_characters_in_list(): |