sissaschool / elementpath

XPath 1.0/2.0/3.0/3.1 parsers and selectors for ElementTree and lxml
MIT License
72 stars 19 forks source link

2.2.3: pytest is failing when `pytest-randomly` is used #39

Closed kloczek closed 3 years ago

kloczek commented 3 years ago

Looks like tehre are some depenndencies between units. Two examples:

+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=1381017335
rootdir: /home/tkloczko/rpmbuild/BUILD/elementpath-2.2.3
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1
collected 1708 items

tests/test_xpath_context.py ....................                                                                                                                     [  1%]
tests/test_helpers.py ......                                                                                                                                         [  1%]
tests/test_schema_context.py .......                                                                                                                                 [  1%]
tests/test_schema_proxy.py ......................................                                                                                                    [  4%]
tests/test_xpath_nodes.py .....................                                                                                                                      [  5%]
tests/test_datatypes.py .................................................................................................................                            [ 12%]
tests/test_xpath2_constructors.py ........................................................................                                                           [ 16%]
tests/test_tdop_parser.py ..FF.....F.........                                                                                                                        [ 17%]
tests/test_exceptions.py ..                                                                                                                                          [ 17%]
tests/test_xpath2_functions.py ..................................................................................................................................... [ 25%]
...................................                                                                                                                                  [ 27%]
tests/test_xpath3.py ............................................................................................................................................... [ 35%]
.................................................................................................................................................................... [ 45%]
.................................................................................................................................................................... [ 54%]
.................................................................................................................................................................... [ 64%]
.........................................................................                                                                                            [ 68%]
tests/test_xpath2_parser.py ........................................................................................................................................ [ 76%]
..................................................................................................................................                                   [ 84%]
tests/test_regex.py ..........................................................                                                                                       [ 87%]
tests/test_namespaces.py ....                                                                                                                                        [ 87%]
tests/test_package.py ..                                                                                                                                             [ 88%]
tests/test_xpath_token.py .................................................                                                                                          [ 90%]
tests/test_xpath1_parser.py ........................................................................................................................................ [ 98%]
...............                                                                                                                                                      [ 99%]
tests/test_selectors.py ....                                                                                                                                         [100%]

================================================================================= FAILURES =================================================================================
______________________________________________________________________ TdopParserTest.test_expression ______________________________________________________________________

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd892cd60>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
>                       self.next_token = self.symbol_table[symbol](self)
E                       KeyError: '+'

elementpath/tdop.py:446: KeyError

During handling of the above exception, another exception occurred:

self = <tests.test_tdop_parser.TdopParserTest testMethod=test_expression>

    def test_expression(self):
>       token = self.parser.parse('10 + 6')

tests/test_tdop_parser.py:139:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
elementpath/tdop.py:412: in parse
    root_token = self.expression()
elementpath/tdop.py:537: in expression
    self.advance()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd892cd60>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
                        self.next_token = self.symbol_table[symbol](self)
                    except KeyError:
                        if self.name_pattern.match(symbol) is None:
                            self.next_token = self.symbol_table['(unknown)'](self, symbol)
>                           raise self.next_token.wrong_syntax()
E                           elementpath.tdop.ParseError: unknown symbol '+'

elementpath/tdop.py:450: ParseError
___________________________________________________________________ TdopParserTest.test_parser_position ____________________________________________________________________

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd892c1c0>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
>                       self.next_token = self.symbol_table[symbol](self)
E                       KeyError: '+'

elementpath/tdop.py:446: KeyError

During handling of the above exception, another exception occurred:

self = <tests.test_tdop_parser.TdopParserTest testMethod=test_parser_position>

    def test_parser_position(self):
        parser = type(self.parser)()
        parser.source = '   7 +\n 8 '
        parser.tokens = iter(parser.tokenizer.finditer(parser.source))
        self.assertIsNone(parser.token)

        parser.advance()
        self.assertIsNone(parser.token)
        self.assertEqual(parser.position, (1, 4))
        self.assertTrue(parser.is_source_start())
        self.assertTrue(parser.is_line_start())
        self.assertFalse(parser.is_spaced())

>       parser.advance()

tests/test_tdop_parser.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd892c1c0>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
                        self.next_token = self.symbol_table[symbol](self)
                    except KeyError:
                        if self.name_pattern.match(symbol) is None:
                            self.next_token = self.symbol_table['(unknown)'](self, symbol)
>                           raise self.next_token.wrong_syntax()
E                           elementpath.tdop.ParseError: unknown symbol '+'

elementpath/tdop.py:450: ParseError
____________________________________________________________________ TdopParserTest.test_advance_until _____________________________________________________________________

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd882f700>, stop_symbols = ('+',)
source_chunk = [' ', '6', ' ', '7', ' '], symbol = '+'

    def advance_until(self, *stop_symbols):
        """
        Advances until one of the symbols is found or the end of source is reached,
        returning the raw source string placed before. Useful for raw parsing of
        comments and references enclosed between specific symbols.

        :param stop_symbols: The symbols that have to be found for stopping advance.
        :return: The source string chunk enclosed between the initial position \
        and the first stop symbol.
        """
        if not stop_symbols:
            raise self.next_token.wrong_type("at least a stop symbol required!")
        elif self.next_token.symbol == '(end)':
            raise self.next_token.wrong_syntax()

        self.token = self.next_token
        source_chunk = []
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                symbol = self.match.group(2)
                if symbol is not None:
                    symbol = symbol.strip()
                    if symbol not in stop_symbols:
                        source_chunk.append(symbol)
                    else:
                        try:
>                           self.next_token = self.symbol_table[symbol](self)
E                           KeyError: '+'

elementpath/tdop.py:518: KeyError

During handling of the above exception, another exception occurred:

self = <tests.test_tdop_parser.TdopParserTest testMethod=test_advance_until>

    def test_advance_until(self):
        parser = type(self.parser)()
        parser.source = ''
        parser.tokens = iter(parser.tokenizer.finditer(parser.source))
        parser.advance()

        with self.assertRaises(TypeError) as ec:
            parser.advance_until()
        self.assertEqual(str(ec.exception), "at least a stop symbol required!")

        with self.assertRaises(ParseError) as ec:
            parser.advance_until('+')
        self.assertEqual(str(ec.exception), "source is empty")

        parser = type(self.parser)()
        parser.source = '5 6 7 + 8'
        parser.tokens = iter(parser.tokenizer.finditer(parser.source))
        parser.advance()
        self.assertEqual(parser.next_token.symbol, '(integer)')
        self.assertEqual(parser.next_token.value, 5)
>       parser.advance_until('+')

tests/test_tdop_parser.py:249:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7f0bd882f700>, stop_symbols = ('+',)
source_chunk = [' ', '6', ' ', '7', ' '], symbol = '+'

    def advance_until(self, *stop_symbols):
        """
        Advances until one of the symbols is found or the end of source is reached,
        returning the raw source string placed before. Useful for raw parsing of
        comments and references enclosed between specific symbols.

        :param stop_symbols: The symbols that have to be found for stopping advance.
        :return: The source string chunk enclosed between the initial position \
        and the first stop symbol.
        """
        if not stop_symbols:
            raise self.next_token.wrong_type("at least a stop symbol required!")
        elif self.next_token.symbol == '(end)':
            raise self.next_token.wrong_syntax()

        self.token = self.next_token
        source_chunk = []
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                symbol = self.match.group(2)
                if symbol is not None:
                    symbol = symbol.strip()
                    if symbol not in stop_symbols:
                        source_chunk.append(symbol)
                    else:
                        try:
                            self.next_token = self.symbol_table[symbol](self)
                            break
                        except KeyError:
                            self.next_token = self.symbol_table['(unknown)'](self)
>                           raise self.next_token.wrong_syntax()
E                           elementpath.tdop.ParseError: unknown symbol '(unknown)'

elementpath/tdop.py:522: ParseError
========================================================================= short test summary info ==========================================================================
FAILED tests/test_tdop_parser.py::TdopParserTest::test_expression - elementpath.tdop.ParseError: unknown symbol '+'
FAILED tests/test_tdop_parser.py::TdopParserTest::test_parser_position - elementpath.tdop.ParseError: unknown symbol '+'
FAILED tests/test_tdop_parser.py::TdopParserTest::test_advance_until - elementpath.tdop.ParseError: unknown symbol '(unknown)'
===================================================================== 3 failed, 1705 passed in 13.41s ======================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=1951671850
rootdir: /home/tkloczko/rpmbuild/BUILD/elementpath-2.2.3
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1
collected 1708 items

tests/test_namespaces.py ....                                                                                                                                        [  0%]
tests/test_tdop_parser.py .................F.                                                                                                                        [  1%]
tests/test_package.py ..                                                                                                                                             [  1%]
tests/test_xpath_nodes.py .....................                                                                                                                      [  2%]
tests/test_selectors.py ....                                                                                                                                         [  2%]
tests/test_schema_context.py .......                                                                                                                                 [  3%]
tests/test_xpath_context.py ....................                                                                                                                     [  4%]
tests/test_helpers.py ......                                                                                                                                         [  4%]
tests/test_xpath2_parser.py ........................................................................................................................................ [ 12%]
..................................................................................................................................                                   [ 20%]
tests/test_xpath2_functions.py ..................................................................................................................................... [ 28%]
...................................                                                                                                                                  [ 30%]
tests/test_datatypes.py .................................................................................................................                            [ 36%]
tests/test_xpath_token.py .................................................                                                                                          [ 39%]
tests/test_xpath2_constructors.py ........................................................................                                                           [ 43%]
tests/test_schema_proxy.py ......................................                                                                                                    [ 46%]
tests/test_exceptions.py ..                                                                                                                                          [ 46%]
tests/test_xpath3.py ............................................................................................................................................... [ 54%]
.................................................................................................................................................................... [ 64%]
.................................................................................................................................................................... [ 73%]
.................................................................................................................................................................... [ 83%]
.........................................................................                                                                                            [ 87%]
tests/test_xpath1_parser.py ........................................................................................................................................ [ 95%]
...............                                                                                                                                                      [ 96%]
tests/test_regex.py ..........................................................                                                                                       [100%]

================================================================================= FAILURES =================================================================================
______________________________________________________________________ TdopParserTest.test_expression ______________________________________________________________________

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7ff766002220>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
>                       self.next_token = self.symbol_table[symbol](self)
E                       KeyError: '+'

elementpath/tdop.py:446: KeyError

During handling of the above exception, another exception occurred:

self = <tests.test_tdop_parser.TdopParserTest testMethod=test_expression>

    def test_expression(self):
>       token = self.parser.parse('10 + 6')

tests/test_tdop_parser.py:139:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
elementpath/tdop.py:412: in parse
    root_token = self.expression()
elementpath/tdop.py:537: in expression
    self.advance()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_tdop_parser.TdopParserTest.setUpClass.<locals>.ExpressionParser object at 0x7ff766002220>, symbols = (), literal = None, symbol = '+', name = None

    def advance(self, *symbols):
        """
        The Pratt's function for advancing to next token.

        :param symbols: Optional arguments tuple. If not empty one of the provided \
        symbols is expected. If the next token's symbol differs the parser raises a \
        parse error.
        :return: The next token instance.
        """
        if self.next_token is not None:
            if self.next_token.symbol == '(end)' or \
                    symbols and self.next_token.symbol not in symbols:
                raise self.next_token.wrong_syntax()

        self.token = self.next_token
        while True:
            try:
                self.match = next(self.tokens)
            except StopIteration:
                self.next_token = self.symbol_table['(end)'](self)
                break
            else:
                literal, symbol, name, unknown = self.match.groups()
                if symbol is not None:
                    try:
                        self.next_token = self.symbol_table[symbol](self)
                    except KeyError:
                        if self.name_pattern.match(symbol) is None:
                            self.next_token = self.symbol_table['(unknown)'](self, symbol)
>                           raise self.next_token.wrong_syntax()
E                           elementpath.tdop.ParseError: unknown symbol '+'

elementpath/tdop.py:450: ParseError
========================================================================= short test summary info ==========================================================================
FAILED tests/test_tdop_parser.py::TdopParserTest::test_expression - elementpath.tdop.ParseError: unknown symbol '+'
===================================================================== 1 failed, 1707 passed in 13.18s ======================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

As long as pytest-randomly is disabled pytest is OK.

+ /usr/bin/pytest -ra -p no:randomly
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/elementpath-2.2.3
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, trio-0.7.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1
collected 1708 items

tests/test_datatypes.py .................................................................................................................                            [  6%]
tests/test_exceptions.py ..                                                                                                                                          [  6%]
tests/test_helpers.py ......                                                                                                                                         [  7%]
tests/test_namespaces.py ....                                                                                                                                        [  7%]
tests/test_package.py ..                                                                                                                                             [  7%]
tests/test_regex.py ..........................................................                                                                                       [ 10%]
tests/test_schema_context.py .......                                                                                                                                 [ 11%]
tests/test_schema_proxy.py ......................................                                                                                                    [ 13%]
tests/test_selectors.py ....                                                                                                                                         [ 13%]
tests/test_tdop_parser.py ...................                                                                                                                        [ 14%]
tests/test_xpath1_parser.py ........................................................................................................................................ [ 22%]
...............                                                                                                                                                      [ 23%]
tests/test_xpath2_constructors.py ........................................................................                                                           [ 27%]
tests/test_xpath2_functions.py ..................................................................................................................................... [ 35%]
...................................                                                                                                                                  [ 37%]
tests/test_xpath2_parser.py ........................................................................................................................................ [ 45%]
..................................................................................................................................                                   [ 53%]
tests/test_xpath3.py ............................................................................................................................................... [ 61%]
.................................................................................................................................................................... [ 71%]
.................................................................................................................................................................... [ 80%]
.................................................................................................................................................................... [ 90%]
.........................................................................                                                                                            [ 94%]
tests/test_xpath_context.py ....................                                                                                                                     [ 95%]
tests/test_xpath_nodes.py .....................                                                                                                                      [ 97%]
tests/test_xpath_token.py .................................................                                                                                          [100%]

========================================================================== 1708 passed in 12.03s ===========================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

To resolve that kind of issues https://github.com/mrbean-bremen/pytest-find-dependencies/ needs to be used.

brunato commented 3 years ago

Hi,

the issue seems to be limited to the TDOP base parser tests. The ExpressionParser's symbol_table might be cleared before the tests are executed.

I tried to reproduce the errors adding a section for pytest to tox.ini:

[testenv:pytest]
deps =
    pytest
    py
    pluggy
    lxml
    xmlschema>=1.2.3
commands =
    pytest tests -ra
#    pytest tests -ra -p no:randomly

but in my case tests run without failures. Maybe i forgot a dependency, I don't know.

brunato commented 3 years ago

Found the problem after adding pytest-randomly package: is a missing statement in TdopParserTest.test_unkown_symbol:

        parser = self.parser.__class__()
        parser.symbol_table = parser.symbol_table.copy()   # duplicate parser class's symbol table
        parser.build()
        parser.symbol_table.pop('+')

Usually a duplication of the symbol table is not needed, but in this case a symbol is removed for testing.

The fix will be available in the next release.

Thanks

kloczek commented 3 years ago

Please let me know when you will have fix for that. I'll be glad to test that ASAP :)

brunato commented 3 years ago

Hi, release v2.3.1 is available. I close this, if it still not works for you reopen the issue.

kloczek commented 3 years ago

Tested three times 2.3.1 without disabled randomly plugin and no fails and all looks clean. Thank you :)

brunato commented 3 years ago

I also added a pytest env to tox.ini for testing this:

[testenv:pytest]
deps =
    pytest
    pytest-randomly
    lxml
    xmlschema>=1.2.3
commands =
    pytest tests -ra