question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.8.2: pytest is failing in `test/test_contrib/test_github_wiki.py::TestGithubWiki::test_parse` unit and `DeprecationWarning` warnings

See original GitHub issue

I’m trying to package 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 build with --no-isolation I’m using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-mistletoe-0.8.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-mistletoe-0.8.2-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/mistletoe-0.8.2
collected 208 items

test/test_ast_renderer.py ..                                                                                                                                         [  0%]
test/test_block_token.py ..................................s...........                                                                                              [ 23%]
test/test_cli.py ...............                                                                                                                                     [ 30%]
test/test_core_tokens.py ...........                                                                                                                                 [ 35%]
test/test_html_renderer.py .............................                                                                                                             [ 49%]
test/test_latex_renderer.py ........................                                                                                                                 [ 61%]
test/test_latex_token.py .                                                                                                                                           [ 61%]
test/test_span_token.py ....................                                                                                                                         [ 71%]
test/test_traverse.py .                                                                                                                                              [ 71%]
test/test_contrib/test_github_wiki.py F.                                                                                                                             [ 72%]
test/test_contrib/test_jira_renderer.py ..................................                                                                                           [ 88%]
test/test_contrib/test_mathjax.py ..                                                                                                                                 [ 89%]
test/test_contrib/test_toc_renderer.py ......                                                                                                                        [ 92%]
test/test_contrib/test_xwiki20_renderer.py ...............                                                                                                           [100%]

================================================================================= FAILURES =================================================================================
________________________________________________________________________ TestGithubWiki.test_parse _________________________________________________________________________

self = <test.test_contrib.test_github_wiki.TestGithubWiki testMethod=test_parse>

    def test_parse(self):
        MockRawText = mock.Mock(autospec='mistletoe.span_token.RawText')
        RawText = _token_types.pop()
        _token_types.append(MockRawText)
        try:
            tokens = tokenize_inner('text with [[wiki | target]]')
            token = tokens[1]
            self.assertIsInstance(token, GithubWiki)
            self.assertEqual(token.target, 'target')
>           MockRawText.assert_has_calls([mock.call('text with '), mock.call('wiki')])

test/test_contrib/test_github_wiki.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <Mock id='140376598689536'>, calls = [call('text with '), call('wiki')], any_order = False

    def assert_has_calls(self, calls, any_order=False):
        """assert the mock has been called with the specified calls.
        The `mock_calls` list is checked for the calls.

        If `any_order` is False (the default) then the calls must be
        sequential. There can be extra calls before or after the
        specified calls.

        If `any_order` is True then the calls can be in any order, but
        they must all appear in `mock_calls`."""
        expected = [self._call_matcher(c) for c in calls]
        cause = next((e for e in expected if isinstance(e, Exception)), None)
        all_calls = _CallList(self._call_matcher(c) for c in self.mock_calls)
        if not any_order:
            if expected not in all_calls:
                if cause is None:
                    problem = 'Calls not found.'
                else:
                    problem = ('Error processing expected calls.\n'
                               'Errors: {}').format(
                                   [e if isinstance(e, Exception) else None
                                    for e in expected])
>               raise AssertionError(
                    f'{problem}\n'
                    f'Expected: {_CallList(calls)}'
                    f'{self._calls_repr(prefix="Actual").rstrip(".")}'
                ) from cause
E               AssertionError: Calls not found.
E               Expected: [call('text with '), call('wiki')]

/usr/lib64/python3.8/unittest/mock.py:950: AssertionError
============================================================================= warnings summary =============================================================================
test/test_span_token.py:102
  /home/tkloczko/rpmbuild/BUILD/mistletoe-0.8.2/test/test_span_token.py:102: DeprecationWarning: invalid escape sequence \*
    self._test_parse(span_token.EscapeSequence, '\*', '*')

test/test_span_token.py:105
  /home/tkloczko/rpmbuild/BUILD/mistletoe-0.8.2/test/test_span_token.py:105: DeprecationWarning: invalid escape sequence \*
    tokens = iter(span_token.tokenize_inner('some \*text*'))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] test/test_block_token.py:309: Even GitHub fails in here, workaround: always put a space before `|`
FAILED test/test_contrib/test_github_wiki.py::TestGithubWiki::test_parse - AssertionError: Calls not found.
=========================================================== 1 failed, 206 passed, 1 skipped, 2 warnings in 0.68s ===========================================================

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kloczekcommented, May 28, 2022

You can ask on pytest discussin forum https://github.com/pytest-dev/pytest/discussions

0reactions
pbodnarcommented, Aug 18, 2022

Fixed by #153, merged into master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found