Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 test fails #161

Closed
yurivict opened this issue Mar 1, 2023 · 5 comments
Closed

1 test fails #161

yurivict opened this issue Mar 1, 2023 · 5 comments

Comments

@yurivict
Copy link

yurivict commented Mar 1, 2023

=============================================================================================== FAILURES ================================================================================================
______________________________________________________________________ test_string_component_transform_factory[1329-example_func8] ______________________________________________________________________

alg = 1329, example_func = functools.partial(<function try_float at 0x8dcdfdca0>, map=True, on_fail=<function <lambda> at 0x8e0987820>, nan=inf)

    @pytest.mark.parametrize(
>       "alg, example_func",
        [
            (ns.INT, partial(try_int, map=True)),
            (ns.DEFAULT, partial(try_int, map=True)),
            (ns.FLOAT, partial(try_float, map=True, nan=float("-inf"))),
            (ns.FLOAT | ns.NANLAST, partial(try_float, map=True, nan=float("+inf"))),
            (ns.GROUPLETTERS, partial(try_int, map=True, on_fail=groupletters)),
            (ns.LOCALE, partial(try_int, map=True, on_fail=lambda x: get_strxfrm()(x))),
            (
                ns.GROUPLETTERS | ns.LOCALE,
                partial(
                    try_int, map=True, on_fail=lambda x: get_strxfrm()(groupletters(x))
                ),
            ),
            (
                NS_DUMB | ns.LOCALE,
                partial(
                    try_int, map=True, on_fail=lambda x: get_strxfrm()(groupletters(x))
                ),
            ),
            (
                ns.GROUPLETTERS | ns.LOCALE | ns.FLOAT | ns.NANLAST,
                partial(
                    try_float,
                    map=True,
                    on_fail=lambda x: get_strxfrm()(groupletters(x)),
                    nan=float("+inf"),
                ),
            ),
        ],
    )

tests/test_string_component_transform_factory.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_string_component_transform_factory.py:80: in test_string_component_transform_factory
    assert list(string_component_transform_func(x)) == list(example_func(x))
natsort/compat/fastnumbers.py:63: in <genexpr>
    return (fast_float(y, nan=nan, key=on_fail) for y in x)
natsort/compat/fake_fastnumbers.py:77: in fast_float
    return _uni(x, key(x)) if len(x) == 1 else key(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

res = 'åÅ', f = <built-in function strxfrm>

>   return partial(reduce, lambda res, f: f(res), functions)
E   OSError: [Errno 22] Invalid argument
E   Falsifying example: test_string_component_transform_factory(
E       x='Å',
E       alg=1329,
E       example_func=functools.partial(<function try_float at 0x8dcdfdca0>, map=True, on_fail=<function <lambda> at 0x8e0987820>, nan=inf),
E   )

natsort/utils.py:841: OSError
=========================================================================================== warnings summary ============================================================================================
../../../../../local/lib/python3.9/site-packages/pytest_freezegun.py:17: 666 warnings
  /usr/local/lib/python3.9/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================= 1 failed, 332 passed, 666 warnings in 30.60s ==============================================================================
*** Error code 1

Version: 8.3.0
Python-3.9
FreeBSD 13.1

@SethMMorton
Copy link
Owner

I cannot reproduce. I'm not even sure how an OSError could be thrown here. I wonder if it is something OS-specific.

Can you do the following and let me know what happens?

$ python3.9 -c "import unicodedata; print(unicodedata.numeric('Å'))"

@yurivict
Copy link
Author

yurivict commented Mar 1, 2023

$ python3.9 -c "import unicodedata; print(unicodedata.numeric('Å'))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: not a numeric character

@SethMMorton
Copy link
Owner

Bummer - that's what I get too. Not an OSError. I'm going to see if I can add BSD to my CI jobs and hopefully that exposes something.

@SethMMorton
Copy link
Owner

SethMMorton commented Mar 1, 2023

Oh my goodness... I can replicate: https://github.com/SethMMorton/natsort/actions/runs/4300958649/jobs/7497664518

I'll solve this tomorrow.

BUT, based on which tests are failing this clearly has something to do with the locale library, which is interesting because I did not touch that in the last update.

@SethMMorton
Copy link
Owner

SethMMorton commented Mar 2, 2023

I can trace this to locale.strxfrm. https://github.com/SethMMorton/natsort/actions/runs/4310592727/jobs/7519180370#step:3:1715

It fails with an OSError when given 'Å'. This is not the first time I have encountered a mind-boggling bug with locale on FreeBSD - sigh. I guess I'll have to add more code to natsort to work around bugs in the locale library with BSD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants