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

test_parse_function_call_as_name and test_repo_line fail on openSUSE #303

Open
mcepl opened this issue Dec 1, 2021 · 2 comments
Open

test_parse_function_call_as_name and test_repo_line fail on openSUSE #303

mcepl opened this issue Dec 1, 2021 · 2 comments

Comments

@mcepl
Copy link

mcepl commented Dec 1, 2021

When testing 1.5.16 while packaging for openSUSE, I get these errors:

[   55s] ____________________________ test_requirement_line _____________________________
[   55s] 
[   55s] self = <[AttributeError("'Requirement' object has no attribute 'name'",) raised in repr()] Requirement object at 0x7f4cbc72fe80>
[   55s] requirement_string = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] 
[   55s]     def __init__(self, requirement_string: str) -> None:
[   55s]         try:
[   55s] >           req = REQUIREMENT.parseString(requirement_string)
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/packaging/requirements.py:102: 
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] 
[   55s] self = {string_start Combine:({W:(0-9A-Za-z) [{W:(0-9A-Za-z) | {[W:(-._)]... W:(0-9A-Za-z)}}]...}) [Suppress:('[') [Combine:(... {string enclosed in "'" | string enclosed in '"'}) | Group:({{Suppress:('(') : ...} Suppress:(') Empty}]}} string_end}
[   55s] instring = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] parse_all = False
[   55s] 
[   55s]     def parse_string(
[   55s]         self, instring: str, parse_all: bool = False, *, parseAll: bool = False
[   55s]     ) -> ParseResults:
[   55s]         """
[   55s]         Parse a string with respect to the parser definition. This function is intended as the primary interface to the
[   55s]         client code.
[   55s]     
[   55s]         :param instring: The input string to be parsed.
[   55s]         :param parse_all: If set, the entire input string must match the grammar.
[   55s]         :param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
[   55s]         :raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
[   55s]         :returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
[   55s]           an object with attributes if the given parser includes results names.
[   55s]     
[   55s]         If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
[   55s]         is also equivalent to ending the grammar with :class:`StringEnd`().
[   55s]     
[   55s]         To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
[   55s]         converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
[   55s]         contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
[   55s]         being parsed, one can ensure a consistent view of the input string by doing one of the following:
[   55s]     
[   55s]         - calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
[   55s]         - define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
[   55s]           parse action's ``s`` argument, or
[   55s]         - explicitly expand the tabs in your input string before calling ``parse_string``.
[   55s]     
[   55s]         Examples:
[   55s]     
[   55s]         By default, partial matches are OK.
[   55s]     
[   55s]         >>> res = Word('a').parse_string('aaaaabaaa')
[   55s]         >>> print(res)
[   55s]         ['aaaaa']
[   55s]     
[   55s]         The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
[   55s]         directly to see more examples.
[   55s]     
[   55s]         It raises an exception if parse_all flag is set and instring does not match the whole grammar.
[   55s]     
[   55s]         >>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
[   55s]         Traceback (most recent call last):
[   55s]         ...
[   55s]         pyparsing.ParseException: Expected end of text, found 'b'  (at char 5), (line:1, col:6)
[   55s]         """
[   55s]         parseAll = parse_all or parseAll
[   55s]     
[   55s]         ParserElement.reset_cache()
[   55s]         if not self.streamlined:
[   55s]             self.streamline()
[   55s]         for e in self.ignoreExprs:
[   55s]             e.streamline()
[   55s]         if not self.keepTabs:
[   55s]             instring = instring.expandtabs()
[   55s]         try:
[   55s]             loc, tokens = self._parse(instring, 0)
[   55s]             if parseAll:
[   55s]                 loc = self.preParse(instring, loc)
[   55s]                 se = Empty() + StringEnd()
[   55s]                 se._parse(instring, loc)
[   55s]         except ParseBaseException as exc:
[   55s]             if ParserElement.verbose_stacktrace:
[   55s]                 raise
[   55s]             else:
[   55s]                 # catch and re-raise exception from here, clearing out pyparsing internal stack trace
[   55s] >               raise exc.with_traceback(None)
[   55s] E               pyparsing.exceptions.ParseException: Expected string_end, found ';'  (at char 7), (line:1, col:8)
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/pyparsing/core.py:1127: ParseException
[   55s] 
[   55s] During handling of the above exception, another exception occurred:
[   55s] 
[   55s]     @given(requirements())
[   55s] >   def test_requirement_line(req):
[   55s] 
[   55s] tests/unit/test_requirements.py:159: 
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] tests/unit/test_requirements.py:160: in test_requirement_line
[   55s]     line = Line(req.line)
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:171: in __init__
[   55s]     self.parse()
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:1295: in parse
[   55s]     self.parse_markers()
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:1186: in parse_markers
[   55s]     markers = PackagingRequirement("fakepkg; {0}".format(marker_str)).marker
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] 
[   55s] self = <[AttributeError("'Requirement' object has no attribute 'name'",) raised in repr()] Requirement object at 0x7f4cbc72fe80>
[   55s] requirement_string = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] 
[   55s]     def __init__(self, requirement_string: str) -> None:
[   55s]         try:
[   55s]             req = REQUIREMENT.parseString(requirement_string)
[   55s]         except ParseException as e:
[   55s]             raise InvalidRequirement(
[   55s] >               f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
[   55s]             )
[   55s] E           packaging.requirements.InvalidRequirement: Parse error at ""; 'extra"": Expected string_end
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/packaging/requirements.py:105: InvalidRequirement
[   55s] ---------------------------------- Hypothesis ----------------------------------
[   55s] Falsifying example: test_requirement_line(
[   55s]     req=NormalRequirement(name='six', specifier='', version=None, extras=[], markers="'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'", hashes=None, line="six; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'", line_without_markers='six', as_list=["six; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"], list_without_markers=['six']),
[   55s] )
[   55s] ________________________________ test_repo_line ________________________________
[   55s] 
[   55s] self = <[AttributeError("'Requirement' object has no attribute 'name'",) raised in repr()] Requirement object at 0x7f4cbc76f860>
[   55s] requirement_string = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] 
[   55s]     def __init__(self, requirement_string: str) -> None:
[   55s]         try:
[   55s] >           req = REQUIREMENT.parseString(requirement_string)
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/packaging/requirements.py:102: 
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] 
[   55s] self = {string_start Combine:({W:(0-9A-Za-z) [{W:(0-9A-Za-z) | {[W:(-._)]... W:(0-9A-Za-z)}}]...}) [Suppress:('[') [Combine:(... {string enclosed in "'" | string enclosed in '"'}) | Group:({{Suppress:('(') : ...} Suppress:(') Empty}]}} string_end}
[   55s] instring = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] parse_all = False
[   55s] 
[   55s]     def parse_string(
[   55s]         self, instring: str, parse_all: bool = False, *, parseAll: bool = False
[   55s]     ) -> ParseResults:
[   55s]         """
[   55s]         Parse a string with respect to the parser definition. This function is intended as the primary interface to the
[   55s]         client code.
[   55s]     
[   55s]         :param instring: The input string to be parsed.
[   55s]         :param parse_all: If set, the entire input string must match the grammar.
[   55s]         :param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
[   55s]         :raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
[   55s]         :returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
[   55s]           an object with attributes if the given parser includes results names.
[   55s]     
[   55s]         If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
[   55s]         is also equivalent to ending the grammar with :class:`StringEnd`().
[   55s]     
[   55s]         To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
[   55s]         converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
[   55s]         contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
[   55s]         being parsed, one can ensure a consistent view of the input string by doing one of the following:
[   55s]     
[   55s]         - calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
[   55s]         - define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
[   55s]           parse action's ``s`` argument, or
[   55s]         - explicitly expand the tabs in your input string before calling ``parse_string``.
[   55s]     
[   55s]         Examples:
[   55s]     
[   55s]         By default, partial matches are OK.
[   55s]     
[   55s]         >>> res = Word('a').parse_string('aaaaabaaa')
[   55s]         >>> print(res)
[   55s]         ['aaaaa']
[   55s]     
[   55s]         The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
[   55s]         directly to see more examples.
[   55s]     
[   55s]         It raises an exception if parse_all flag is set and instring does not match the whole grammar.
[   55s]     
[   55s]         >>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
[   55s]         Traceback (most recent call last):
[   55s]         ...
[   55s]         pyparsing.ParseException: Expected end of text, found 'b'  (at char 5), (line:1, col:6)
[   55s]         """
[   55s]         parseAll = parse_all or parseAll
[   55s]     
[   55s]         ParserElement.reset_cache()
[   55s]         if not self.streamlined:
[   55s]             self.streamline()
[   55s]         for e in self.ignoreExprs:
[   55s]             e.streamline()
[   55s]         if not self.keepTabs:
[   55s]             instring = instring.expandtabs()
[   55s]         try:
[   55s]             loc, tokens = self._parse(instring, 0)
[   55s]             if parseAll:
[   55s]                 loc = self.preParse(instring, loc)
[   55s]                 se = Empty() + StringEnd()
[   55s]                 se._parse(instring, loc)
[   55s]         except ParseBaseException as exc:
[   55s]             if ParserElement.verbose_stacktrace:
[   55s]                 raise
[   55s]             else:
[   55s]                 # catch and re-raise exception from here, clearing out pyparsing internal stack trace
[   55s] >               raise exc.with_traceback(None)
[   55s] E               pyparsing.exceptions.ParseException: Expected string_end, found ';'  (at char 7), (line:1, col:8)
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/pyparsing/core.py:1127: ParseException
[   55s] 
[   55s] During handling of the above exception, another exception occurred:
[   55s] 
[   55s]     @settings(deadline=None)
[   55s] >   @given(repository_line())
[   55s]     def test_repo_line(repo_line):
[   55s] 
[   55s] tests/unit/test_requirements.py:171: 
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] tests/unit/test_requirements.py:181: in test_repo_line
[   55s]     assert (
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:171: in __init__
[   55s]     self.parse()
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:1295: in parse
[   55s]     self.parse_markers()
[   55s] ../../BUILDROOT/python-requirementslib-1.5.16-0.x86_64/usr/lib/python3.6/site-packages/requirementslib/models/requirements.py:1186: in parse_markers
[   55s]     markers = PackagingRequirement("fakepkg; {0}".format(marker_str)).marker
[   55s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   55s] 
[   55s] self = <[AttributeError("'Requirement' object has no attribute 'name'",) raised in repr()] Requirement object at 0x7f4cbc76f860>
[   55s] requirement_string = "fakepkg; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'"
[   55s] 
[   55s]     def __init__(self, requirement_string: str) -> None:
[   55s]         try:
[   55s]             req = REQUIREMENT.parseString(requirement_string)
[   55s]         except ParseException as e:
[   55s]             raise InvalidRequirement(
[   55s] >               f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
[   55s]             )
[   55s] E           packaging.requirements.InvalidRequirement: Parse error at ""; 'extra"": Expected string_end
[   55s] 
[   55s] /usr/lib/python3.6/site-packages/packaging/requirements.py:105: InvalidRequirement
[   55s] ---------------------------------- Hypothesis ----------------------------------
[   55s] Falsifying example: test_repo_line(
[   55s]     repo_line="-e git+http://github.com/sarugaku/pythonfinder.git@master#egg=pythonfinder; 'extra' '!=' '#1 SMP Fri Apr 25 13:07:35 EDT 2014 Java HotSpot(TM) 64-Bit Server VM, 25.51-b03, Oracle Corporation Darwin Kernel Version 14.5.0: Wed Jul 29 02:18:53 PDT 2015; root:xnu-2782.40.9~2/RELEASE_X86_64'",
[   55s] )
[   55s] =============================== warnings summary ===============================
[   55s] tests/conftest.py:48
[   55s]   /home/abuild/rpmbuild/BUILD/requirementslib-1.5.16/tests/conftest.py:48: RuntimeWarning: Failed connecting to internet: http://clients3.google.com/generate_204
[   55s]     warnings.warn("Failed connecting to internet: {0}".format(url), RuntimeWarning)
[   55s] 
[   55s] ../../../../../usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233
[   55s]   /usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: flake8-ignore
[   55s]   
[   55s]     self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
[   55s] 
[   55s] ../../../../../usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233
[   55s]   /usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: plugins
[   55s]   
[   55s]     self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
[   55s] 
[   55s] ../../../../../usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233
[   55s]   /usr/lib/python3.6/site-packages/_pytest/config/__init__.py:1233: PytestConfigWarning: Unknown config option: strict
[   55s]   
[   55s]     self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
[   55s] 
[   55s] -- Docs: https://docs.pytest.org/en/stable/warnings.html
[   55s] =========================== short test summary info ============================
[   55s] FAILED tests/unit/test_requirements.py::test_requirement_line - packaging.req...
[   55s] FAILED tests/unit/test_requirements.py::test_repo_line - packaging.requiremen...
[   55s] ========== 2 failed, 167 passed, 20 deselected, 4 warnings in 12.38s ===========

Complete build log with all versions of packages used and steps taken to achieve this point.

It seems to me there are many errors with openSUSE. Is it because we do something wrong or because nobody else tests their packages?

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Dec 9, 2021
https://build.opensuse.org/request/show/935085
by user mcepl + dimstar_suse
- Skip failing tests test_parse_function_call_as_name,
  test_repo_line, and test_requirement_line
  (gh#sarugaku/requirementslib#303).
@felixonmars
Copy link
Contributor

We are having the same test failures on Arch, also with the newer 1.6.0 release.

@bnavigator
Copy link

FYI we removed the package from openSUSE because it was just not possible to maintain. https://build.opensuse.org/request/show/941716

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

3 participants