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

Tests failing on Fedora 38, 39 (python 3.11) #21

Closed
jonathanspw opened this issue Jul 3, 2023 · 4 comments
Closed

Tests failing on Fedora 38, 39 (python 3.11) #21

jonathanspw opened this issue Jul 3, 2023 · 4 comments

Comments

@jonathanspw
Copy link

============================= test session starts ==============================
platform linux -- Python 3.11.4, pytest-7.1.3, pluggy-1.0.0
cachedir: .tox/py311/.pytest_cache
rootdir: /builddir/build/BUILD/parse_type-0.6.1, configfile: pytest.ini, testpaths: tests
collected 222 items

tests/test_builder.py .........................                          [ 11%]
tests/test_cardinality.py ................................               [ 25%]
tests/test_cardinality_field.py ..........................               [ 37%]
tests/test_cfparse.py .........                                          [ 41%]
tests/test_parse.py ............................................F....... [ 64%]
..............FF..............                                           [ 78%]
tests/test_parse_decorator.py .....                                      [ 80%]
tests/test_parse_number.py ..........                                    [ 85%]
tests/test_parse_util.py .................................               [100%]

=================================== FAILURES ===================================
_____________________________ TestParse.test_sign ______________________________

self = <tests.test_parse.TestParse testMethod=test_sign>

    def test_sign(self):
        # sign is ignored
        r = parse.parse('Pi = {:.7f}', 'Pi = 3.1415926')
        self.assertEqual(r.fixed, (3.1415926,))
>       r = parse.parse('Pi = {:+.7f}', 'Pi = 3.1415926')

tests/test_parse.py:234:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.11/site-packages/parse.py:1374: in parse
    p = Parser(format, extra_types=extra_types, case_sensitive=case_sensitive)
/usr/lib/python3.11/site-packages/parse.py:833: in __init__
    self._expression = self._generate_expression()
/usr/lib/python3.11/site-packages/parse.py:1006: in _generate_expression
    e.append(self._handle_field(part))
/usr/lib/python3.11/site-packages/parse.py:1078: in _handle_field
    format = extract_format(format, self._extra_types)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

format = '+.7f', extra_types = {}

    def extract_format(format, extra_types):
        """Pull apart the format [[fill]align][0][width][.precision][type]"""
        fill = align = None
        if format[0] in '<>=^':
            align = format[0]
            format = format[1:]
        elif len(format) > 1 and format[1] in '<>=^':
            fill = format[0]
            align = format[1]
            format = format[2:]

        zero = False
        if format and format[0] == '0':
            zero = True
            format = format[1:]

        width = ''
        while format:
            if not format[0].isdigit():
                break
            width += format[0]
            format = format[1:]

        if format.startswith('.'):
            # Precision isn't needed but we need to capture it so that
            # the ValueError isn't raised.
            format = format[1:]  # drop the '.'
            precision = ''
            while format:
                if not format[0].isdigit():
                    break
                precision += format[0]
                format = format[1:]

        # the rest is the type, if present
        type = format
        if type and type not in ALLOWED_TYPES and type not in extra_types:
>           raise ValueError('format spec %r not recognised' % type)
E           ValueError: format spec '+.7f' not recognised

/usr/lib/python3.11/site-packages/parse.py:797: ValueError
_________________ TestBugs.test_unused_centered_alignment_bug __________________

self = <tests.test_parse.TestBugs testMethod=test_unused_centered_alignment_bug>

    def test_unused_centered_alignment_bug(self):
        r = parse.parse("{:^2S}", "foo")
>       self.assertEqual(r[0], "foo")
E       TypeError: 'NoneType' object is not subscriptable

tests/test_parse.py:904: TypeError
___________________ TestBugs.test_unused_left_alignment_bug ____________________

self = <tests.test_parse.TestBugs testMethod=test_unused_left_alignment_bug>

    def test_unused_left_alignment_bug(self):
        r = parse.parse("{:<2S}", "foo")
>       self.assertEqual(r[0], "foo")
E       TypeError: 'NoneType' object is not subscriptable

tests/test_parse.py:915: TypeError
=========================== short test summary info ============================
FAILED tests/test_parse.py::TestParse::test_sign - ValueError: format spec '+...
FAILED tests/test_parse.py::TestBugs::test_unused_centered_alignment_bug - Ty...
FAILED tests/test_parse.py::TestBugs::test_unused_left_alignment_bug - TypeEr...
======================== 3 failed, 219 passed in 0.15s =========================
ERROR: InvocationError for command /usr/bin/pytest tests (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py311: commands failed

I'm not too sure what to make of these errors but they're preventing me from updating the Fedora package to 0.6.1.

Any ideas?

@jenisys
Copy link
Owner

jenisys commented Jul 3, 2023

Mmh, I just rerun the tests for the current HEAD of the main branch (== v0.6.1) and all tests pass on ubuntu-latest (and macOS, …).

  • The CI build uses also Python 3.11.4
  • test_parse.py basically tests the installed parse module
    ENSURE: parse v1.19.1 must be used. Otherwise, use pip install -U parse to update it.
    HINT: parse v1.19.1 reverted some fix that was used before.

QUESTIONS:

  • How did you install the package: via https://pypi.org , from the Git repo or … ?

SEE ALSO:

@jenisys jenisys closed this as completed in 014f1a2 Jul 4, 2023
@jenisys
Copy link
Owner

jenisys commented Jul 4, 2023

@jonathanspw
Try to install parse_type v0.6.2 from the git repository (for now) to verify that the problem is fixed for you, like:

pip install -U git+https://github.com/jenisys/parse_type@v0.6.2

@jonathanspw
Copy link
Author

@jonathanspw Try to install parse_type v0.6.2 from the git repository (for now) to verify that the problem is fixed for you, like:

pip install -U git+https://github.com/jenisys/parse_type@v0.6.2

All tests pass now, thanks!

@jenisys
Copy link
Owner

jenisys commented Jul 5, 2023

@jonathanspw
Published on https://pypi.org now.

SEE ALSO: https://pypi.org/project/parse-type/0.6.2/

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