1.4.7: pytest is failing in three units
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation- because I'm calling
buildwith--no-isolationI'm using during all processes only locally installed modules - install .whl file in </install/prefix> using 'installer` module
- run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
- build is performed in env which is
cut off from access to the public network(pytest is executed with-m "not network")
Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-snuggs-1.4.7-14.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-snuggs-1.4.7-14.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.17, pytest-7.4.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/snuggs-1.4.7
plugins: hypothesis-6.75.3
collected 37 items
test_snuggs.py ..........X...................F.F.F.. [100%]
========================================================================================= FAILURES ==========================================================================================
________________________________________________________________________________ test_missing_closing_paren _________________________________________________________________________________
self = ')', instring = '(+ 1 2', loc = 6, doActions = True, callPreParse = False
def _parseNoCache(
self, instring, loc, doActions=True, callPreParse=True
) -> Tuple[int, ParseResults]:
TRY, MATCH, FAIL = 0, 1, 2
debugging = self.debug # and doActions)
len_instring = len(instring)
if debugging or self.failAction:
# print("Match {} at loc {}({}, {})".format(self, loc, lineno(loc, instring), col(loc, instring)))
try:
if callPreParse and self.callPreparse:
pre_loc = self.preParse(instring, loc)
else:
pre_loc = loc
tokens_start = pre_loc
if self.debugActions.debug_try:
self.debugActions.debug_try(instring, tokens_start, self, False)
if self.mayIndexError or pre_loc >= len_instring:
try:
loc, tokens = self.parseImpl(instring, pre_loc, doActions)
except IndexError:
raise ParseException(instring, len_instring, self.errmsg, self)
else:
loc, tokens = self.parseImpl(instring, pre_loc, doActions)
except Exception as err:
# print("Exception raised:", err)
if self.debugActions.debug_fail:
self.debugActions.debug_fail(
instring, tokens_start, self, err, False
)
if self.failAction:
self.failAction(instring, tokens_start, self, err)
raise
else:
if callPreParse and self.callPreparse:
pre_loc = self.preParse(instring, loc)
else:
pre_loc = loc
tokens_start = pre_loc
if self.mayIndexError or pre_loc >= len_instring:
try:
> loc, tokens = self.parseImpl(instring, pre_loc, doActions)
/usr/lib/python3.8/site-packages/pyparsing/core.py:845:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = ')', instring = '(+ 1 2', loc = 6, doActions = True
def parseImpl(self, instring, loc, doActions=True):
> if instring[loc] == self.firstMatchChar:
E IndexError: string index out of range
/usr/lib/python3.8/site-packages/pyparsing/core.py:2471: IndexError
During handling of the above exception, another exception occurred:
line = '(+ 1 2'
def handleLine(line):
try:
> result = expr.parseString(line)
snuggs/__init__.py:185:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pyparsing/util.py:256: in _inner
return fn(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = {Forward: Group:({{{Suppress:('(') map | partial} {{{'nil' | : ...} | * | + | / | - | & | | | <= | < | == | != | >= | .... | : ...} | 'nil'} | identifier} | number} | {string enclosed in "'" | string enclosed in '"'}}]...} Suppress:(')')})}
instring = '(+ 1 2', parse_all = False
def parse_string(
self, instring: str, parse_all: bool = False, *, parseAll: bool = False
) -> ParseResults:
"""
Parse a string with respect to the parser definition. This function is intended as the primary interface to the
client code.
:param instring: The input string to be parsed.
:param parse_all: If set, the entire input string must match the grammar.
:param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
:raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
:returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
an object with attributes if the given parser includes results names.
If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
is also equivalent to ending the grammar with :class:`StringEnd`\\ ().
To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
being parsed, one can ensure a consistent view of the input string by doing one of the following:
- calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
- define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
parse action's ``s`` argument, or
- explicitly expand the tabs in your input string before calling ``parse_string``.
Examples:
By default, partial matches are OK.
>>> res = Word('a').parse_string('aaaaabaaa')
>>> print(res)
['aaaaa']
The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
directly to see more examples.
It raises an exception if parse_all flag is set and instring does not match the whole grammar.
>>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
Traceback (most recent call last):
...
pyparsing.ParseException: Expected end of text, found 'b' (at char 5), (line:1, col:6)
"""
parseAll = parse_all or parseAll
ParserElement.reset_cache()
if not self.streamlined:
self.streamline()
for e in self.ignoreExprs:
e.streamline()
if not self.keepTabs:
instring = instring.expandtabs()
try:
loc, tokens = self._parse(instring, 0)
if parseAll:
loc = self.preParse(instring, loc)
se = Empty() + StringEnd()
se._parse(instring, loc)
except ParseBaseException as exc:
if ParserElement.verbose_stacktrace:
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
> raise exc.with_traceback(None)
E pyparsing.exceptions.ParseException: , found end of text (at char 6), (line:1, col:7)
/usr/lib/python3.8/site-packages/pyparsing/core.py:1190: ParseException
During handling of the above exception, another exception occurred:
def test_missing_closing_paren():
with pytest.raises(SyntaxError) as excinfo:
> snuggs.eval("(+ 1 2")
test_snuggs.py:196:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
snuggs/__init__.py:218: in eval
return handleLine(source)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
line = '(+ 1 2'
def handleLine(line):
try:
result = expr.parseString(line)
return processList(result[0])
except ParseException as exc:
text = str(exc)
m = re.search(r'(Expected .+) \(at char (\d+)\), \(line:(\d+)', text)
> msg = m.group(1)
E AttributeError: 'NoneType' object has no attribute 'group'
snuggs/__init__.py:190: AttributeError
____________________________________________________________________________________ test_missing_func2 _____________________________________________________________________________________
line = '(# 1 2)'
def handleLine(line):
try:
> result = expr.parseString(line)
snuggs/__init__.py:185:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pyparsing/util.py:256: in _inner
return fn(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = {Forward: Group:({{{Suppress:('(') map | partial} {{{'nil' | : ...} | * | + | / | - | & | | | <= | < | == | != | >= | .... | : ...} | 'nil'} | identifier} | number} | {string enclosed in "'" | string enclosed in '"'}}]...} Suppress:(')')})}
instring = '(# 1 2)', parse_all = False
def parse_string(
self, instring: str, parse_all: bool = False, *, parseAll: bool = False
) -> ParseResults:
"""
Parse a string with respect to the parser definition. This function is intended as the primary interface to the
client code.
:param instring: The input string to be parsed.
:param parse_all: If set, the entire input string must match the grammar.
:param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
:raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
:returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
an object with attributes if the given parser includes results names.
If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
is also equivalent to ending the grammar with :class:`StringEnd`\\ ().
To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
being parsed, one can ensure a consistent view of the input string by doing one of the following:
- calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
- define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
parse action's ``s`` argument, or
- explicitly expand the tabs in your input string before calling ``parse_string``.
Examples:
By default, partial matches are OK.
>>> res = Word('a').parse_string('aaaaabaaa')
>>> print(res)
['aaaaa']
The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
directly to see more examples.
It raises an exception if parse_all flag is set and instring does not match the whole grammar.
>>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
Traceback (most recent call last):
...
pyparsing.ParseException: Expected end of text, found 'b' (at char 5), (line:1, col:6)
"""
parseAll = parse_all or parseAll
ParserElement.reset_cache()
if not self.streamlined:
self.streamline()
for e in self.ignoreExprs:
e.streamline()
if not self.keepTabs:
instring = instring.expandtabs()
try:
loc, tokens = self._parse(instring, 0)
if parseAll:
loc = self.preParse(instring, loc)
se = Empty() + StringEnd()
se._parse(instring, loc)
except ParseBaseException as exc:
if ParserElement.verbose_stacktrace:
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
> raise exc.with_traceback(None)
E pyparsing.exceptions.ParseException: , found '#' (at char 1), (line:1, col:2)
/usr/lib/python3.8/site-packages/pyparsing/core.py:1190: ParseException
During handling of the above exception, another exception occurred:
def test_missing_func2():
with pytest.raises(SyntaxError) as excinfo:
> snuggs.eval("(# 1 2)")
test_snuggs.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
snuggs/__init__.py:218: in eval
return handleLine(source)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
line = '(# 1 2)'
def handleLine(line):
try:
result = expr.parseString(line)
return processList(result[0])
except ParseException as exc:
text = str(exc)
m = re.search(r'(Expected .+) \(at char (\d+)\), \(line:(\d+)', text)
> msg = m.group(1)
E AttributeError: 'NoneType' object has no attribute 'group'
snuggs/__init__.py:190: AttributeError
_______________________________________________________________________________ test_bogus_higher_order_func ________________________________________________________________________________
line = '((bogus * 2) 2)'
def handleLine(line):
try:
> result = expr.parseString(line)
snuggs/__init__.py:185:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pyparsing/util.py:256: in _inner
return fn(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = {Forward: Group:({{{Suppress:('(') map | partial} {{{'nil' | : ...} | * | + | / | - | & | | | <= | < | == | != | >= | .... | : ...} | 'nil'} | identifier} | number} | {string enclosed in "'" | string enclosed in '"'}}]...} Suppress:(')')})}
instring = '((bogus * 2) 2)', parse_all = False
def parse_string(
self, instring: str, parse_all: bool = False, *, parseAll: bool = False
) -> ParseResults:
"""
Parse a string with respect to the parser definition. This function is intended as the primary interface to the
client code.
:param instring: The input string to be parsed.
:param parse_all: If set, the entire input string must match the grammar.
:param parseAll: retained for pre-PEP8 compatibility, will be removed in a future release.
:raises ParseException: Raised if ``parse_all`` is set and the input string does not match the whole grammar.
:returns: the parsed data as a :class:`ParseResults` object, which may be accessed as a `list`, a `dict`, or
an object with attributes if the given parser includes results names.
If the input string is required to match the entire grammar, ``parse_all`` flag must be set to ``True``. This
is also equivalent to ending the grammar with :class:`StringEnd`\\ ().
To report proper column numbers, ``parse_string`` operates on a copy of the input string where all tabs are
converted to spaces (8 spaces per tab, as per the default in ``string.expandtabs``). If the input string
contains tabs and the grammar uses parse actions that use the ``loc`` argument to index into the string
being parsed, one can ensure a consistent view of the input string by doing one of the following:
- calling ``parse_with_tabs`` on your grammar before calling ``parse_string`` (see :class:`parse_with_tabs`),
- define your parse action using the full ``(s,loc,toks)`` signature, and reference the input string using the
parse action's ``s`` argument, or
- explicitly expand the tabs in your input string before calling ``parse_string``.
Examples:
By default, partial matches are OK.
>>> res = Word('a').parse_string('aaaaabaaa')
>>> print(res)
['aaaaa']
The parsing behavior varies by the inheriting class of this abstract class. Please refer to the children
directly to see more examples.
It raises an exception if parse_all flag is set and instring does not match the whole grammar.
>>> res = Word('a').parse_string('aaaaabaaa', parse_all=True)
Traceback (most recent call last):
...
pyparsing.ParseException: Expected end of text, found 'b' (at char 5), (line:1, col:6)
"""
parseAll = parse_all or parseAll
ParserElement.reset_cache()
if not self.streamlined:
self.streamline()
for e in self.ignoreExprs:
e.streamline()
if not self.keepTabs:
instring = instring.expandtabs()
try:
loc, tokens = self._parse(instring, 0)
if parseAll:
loc = self.preParse(instring, loc)
se = Empty() + StringEnd()
se._parse(instring, loc)
except ParseBaseException as exc:
if ParserElement.verbose_stacktrace:
raise
else:
# catch and re-raise exception from here, clearing out pyparsing internal stack trace
> raise exc.with_traceback(None)
E pyparsing.exceptions.ParseException: , found 'bogus' (at char 2), (line:1, col:3)
/usr/lib/python3.8/site-packages/pyparsing/core.py:1190: ParseException
During handling of the above exception, another exception occurred:
def test_bogus_higher_order_func():
with pytest.raises(SyntaxError) as excinfo:
> snuggs.eval("((bogus * 2) 2)")
test_snuggs.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
snuggs/__init__.py:218: in eval
return handleLine(source)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
line = '((bogus * 2) 2)'
def handleLine(line):
try:
result = expr.parseString(line)
return processList(result[0])
except ParseException as exc:
text = str(exc)
m = re.search(r'(Expected .+) \(at char (\d+)\), \(line:(\d+)', text)
> msg = m.group(1)
E AttributeError: 'NoneType' object has no attribute 'group'
snuggs/__init__.py:190: AttributeError
================================================================================== short test summary info ==================================================================================
XPASS test_snuggs.py::test_arr_lookup_kwarg_order Keyword argument order can't be relied on
FAILED test_snuggs.py::test_missing_closing_paren - AttributeError: 'NoneType' object has no attribute 'group'
FAILED test_snuggs.py::test_missing_func2 - AttributeError: 'NoneType' object has no attribute 'group'
FAILED test_snuggs.py::test_bogus_higher_order_func - AttributeError: 'NoneType' object has no attribute 'group'
========================================================================== 3 failed, 33 passed, 1 xpassed in 1.49s ==========================================================================
Here is list of installed modules in build env
Package Version
----------------------------- -------
alabaster 0.7.13
asttokens 2.2.1
attrs 23.1.0
Babel 2.12.1
backcall 0.2.0
build 0.10.0
charset-normalizer 3.1.0
decorator 5.1.1
distro 1.8.0
docutils 0.19
exceptiongroup 1.1.1
executing 1.2.0
gpg 1.20.0
hypothesis 6.75.3
idna 3.4
imagesize 1.4.1
importlib-metadata 6.7.0
iniconfig 2.0.0
installer 0.7.0
ipython 8.12.0
jedi 0.18.2
Jinja2 3.1.2
libcomps 0.1.19
MarkupSafe 2.1.2
matplotlib-inline 0.1.6
numpy 1.24.3
packaging 23.1
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pluggy 1.0.0
prompt-toolkit 3.0.38
ptyprocess 0.7.0
pure-eval 0.2.2
Pygments 2.15.1
pyparsing 3.1.0
pyproject_hooks 1.0.0
pytest 7.4.0
python-dateutil 2.8.2
pytz 2023.2
requests 2.31.0
setuptools 68.0.0
six 1.16.0
snowballstemmer 2.2.0
sortedcontainers 2.4.0
Sphinx 6.2.1
sphinxcontrib-applehelp 1.0.4
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
stack-data 0.6.2
tomli 2.0.1
traitlets 5.9.0
typing_extensions 4.6.3
urllib3 1.26.15
wcwidth 0.2.6
wheel 0.40.0
zipp 3.15.0
+1 from the openSUSE Python packager.
Complete build log with all details of packages used and steps taken to reproduce.
The Debian package works around this with xfail:
https://salsa.debian.org/debian-gis-team/python-snuggs/-/blob/master/debian/patches/test.patch
This is a MapBox project which hasn't seen activity in 4 years which doesn't give high hopes for a fix.
Once rasterio drops its dependency on snuggs we can drop the package.
The Debian package works around this with xfail:
Can you submit that as PR?