executablebooks / mdit-py-plugins

Collection of core plugins for markdown-it-py
https://mdit-py-plugins.readthedocs.io
MIT License
30 stars 32 forks source link

0.4.0: pytest is failing #89

Closed kloczek closed 2 months ago

kloczek commented 1 year ago

Describe the bug

Looks like with new version pytest is failing in few units.

Reproduce the bug

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.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-mdit-py-plugins-0.4.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-mdit-py-plugins-0.4.0-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.16, pytest-7.3.1, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/mdit-py-plugins-0.4.0 plugins: datadir-1.4.1, regressions-2.4.2 collected 410 items tests/test_admon.py .....................F... [ 6%] tests/test_amsmath.py ...................F [ 10%] tests/test_anchors.py ........ [ 12%] tests/test_attrs.py ...............................F [ 20%] tests/test_colon_fence.py ................................F. [ 29%] tests/test_container.py ......................F [ 34%] tests/test_deflist.py ...............F [ 38%] tests/test_dollarmath.py ...............................................................F [ 54%] tests/test_field_list.py ................F [ 58%] tests/test_footnote.py ......................F [ 63%] tests/test_front_matter.py ......... [ 66%] tests/test_myst_block.py ..............F.. [ 70%] tests/test_myst_role.py ............... [ 73%] tests/test_substitution.py .......... [ 76%] tests/test_tasklists.py ....... [ 78%] tests/test_texmath.py ....................................................................................... [ 99%] tests/test_wordcount.py ... [100%] ========================================================================================= FAILURES ========================================================================================== _ test_all[306-Indented by 4 spaces, DISABLE-CODEBLOCKS- ??? note\n content\n-
\n

Note

\n

content

\n
\n] _ line = 306, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' ??? note\n content\n' expected = '
\n

Note

\n

content

\n
\n' @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH.joinpath("fixtures", "admon.md")), ) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(admon_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

??? note\ncontent

' == '
E -

Note

E -

content

E ? --- - E + content

E -
tests/test_admon.py:24: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

??? note content

_ test_fixtures[237-Indented by 4 spaces, DISABLE-CODEBLOCKS- \\begin{equation}\n a = 1\n \\end{equation}\n-
\n\\begin{equation}\n a = 1\n \\end{equation}\n
\n] _ line = 237, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' \\begin{equation}\n a = 1\n \\end{equation}\n' expected = '
\n\\begin{equation}\n a = 1\n \\end{equation}\n
\n' @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH.joinpath("fixtures", "amsmath.md")), ) def test_fixtures(line, title, input, expected): md = MarkdownIt("commonmark").use(amsmath_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

\\begin{e...equation}

' == '
E - \begin{equation} E +

\begin{equation} E ? +++ E - a = 1 E ? ---- E + a = 1... E E ...Full output truncated (5 lines hidden), use '-vv' to show tests/test_amsmath.py:58: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

\begin{equation} a = 1 \end{equation}

_______________________________ test_attrs[254-Indented by 4 spaces, DISABLE-CODEBLOCKS- {#a .a b=c}\n # head\n-

head

\n] _______________________________ line = 254, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' {#a .a b=c}\n # head\n', expected = '

head

\n' @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH / "attrs.md") ) def test_attrs(line, title, input, expected): md = MarkdownIt("commonmark").use(attrs_plugin, spans=True).use(attrs_block_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

{#a .a b=c}\n# head

' == '

head

' E -

head

E +

{#a .a b=c} E + # head

tests/test_attrs.py:22: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

{#a .a b=c} # head

______________________ test_fixtures[438-Indented by 4 spaces, DISABLE-CODEBLOCKS- :::name\n foo\n :::\n-
foo\n
\n] ______________________ line = 438, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' :::name\n foo\n :::\n', expected = '
foo\n
\n' @pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) def test_fixtures(line, title, input, expected): md = MarkdownIt("commonmark").use(colon_fence_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) try: > assert text.rstrip() == expected.rstrip() E assert '

:::name\nfoo\n:::

' == '
' E -
foo
E             - 
E +

:::name E + foo E + :::

tests/test_colon_fence.py:21: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

:::name foo :::

_________________________ test_all[301-Indented by 4 spaces, DISABLE-CODEBLOCKS- ::: name\n content\n :::\n-
\n

content

\n
\n] __________________________ line = 301, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' ::: name\n content\n :::\n', expected = '
\n

content

\n
\n' @pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(container_plugin, "name") if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

::: name\...tent\n:::

' == '
E -

content

E -
E +

::: name E + content E + :::

tests/test_container.py:50: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

::: name content :::

______________________ test_all[261-Indented by 4 spaces, DISABLE-CODEBLOCKS- Term 1\n\n : Definition 1\n-
\n
Term 1
\n
Definition 1
\n
\n] ______________________ line = 261, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' Term 1\n\n : Definition 1\n', expected = '
\n
Term 1
\n
Definition 1
\n
\n' @pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(deflist_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E AssertionError: assert '

Term 1' == '

\n
Te...1\n
' E -
E -
Term 1
E ? ^^ ^^ E +

Term 1

E ? ^ ^ E -
Definition 1
E ? ^^ ^^ -... E E ...Full output truncated (3 lines hidden), use '-vv' to show tests/test_deflist.py:39: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

Term 1

: Definition 1

_________________________________ test_dollarmath_fixtures[575-Indented by 4 spaces, DISABLE-CODEBLOCKS- $$a$$\n-
\na\n
\n] __________________________________ line = 575, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' $$a$$\n', expected = '
\na\n
\n' @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH.joinpath("dollar_math.md")), ) def test_dollarmath_fixtures(line, title, input, expected): md = MarkdownIt("commonmark").use( dollarmath_plugin, allow_space=False, allow_digits=False, double_inline=True, allow_blank_lines=False, ) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options.xhtmlOut = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

a

' == '
\na\n
' E +

a

E -
E - a E -
tests/test_dollarmath.py:106: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

a

__________________________________________________________________ test_all[378-Indented_by_4_spaces,_DISABLE-CODEBLOCKS] ___________________________________________________________________ line = 378, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' :name: text\n indented\n' expected = '
\n
name
\n
\n

text\nindented

\n
\n
\n' @pytest.mark.parametrize( "line,title,input,expected", fixtures, ids=[f"{f[0]}-{f[1].replace(' ', '_')}" for f in fixtures], ) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(fieldlist_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

:name: text\nindented

' == '
E -
name
E -
E -

text E - indented

E ? -... E E ...Full output truncated (3 lines hidden), use '-vv' to show tests/test_field_list.py:41: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

:name: text indented

_ test_all[360-Indented by 4 spaces, DISABLE-CODEBLOCKS- [^1]\n\n [^1]: footnote\n-

[1]

\n
\n
\n
    \n
  1. footnote \u21a9\ufe0e

    \n
  2. \n
\n
\n] _ line = 360, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' [^1]\n\n [^1]: footnote\n' expected = '

[1]

\n
\n

footnote ↩︎

\n\n\n
\n' @pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(footnote_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip().replace("↩︎", "<-").replace( "↩", "<-" ) == expected.rstrip().replace("↩︎", "<-").replace("↩", "<-") E assert '

[^1]

\... footnote

' == '

\n' E +

[^1]

E +

[^1]: footnote

E -

[1]

E -
E -
E -
    E -
  1. footnote <-

    ... E E ...Full output truncated (3 lines hidden), use '-vv' to show tests/test_footnote.py:459: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

    [^1]

    [^1]: footnote

    ___ test_all[168-Indented by 4 spaces, DISABLE-CODEBLOCKS- +++\n\n % abc\n\n (a)=\n-
    \n\n] ___ line = 168, title = 'Indented by 4 spaces, DISABLE-CODEBLOCKS', input = ' +++\n\n % abc\n\n (a)=\n' expected = '
    \n\n' @pytest.mark.parametrize("line,title,input,expected", read_fixture_file(FIXTURE_PATH)) def test_all(line, title, input, expected): md = MarkdownIt("commonmark").use(myst_block_plugin) if "DISABLE-CODEBLOCKS" in title: md.disable("code") md.options["xhtmlOut"] = False text = md.render(input) print(text) > assert text.rstrip() == expected.rstrip() E assert '

    +++

    \n...\n

    (a)=

    ' == '
    E - E +

    +++

    E +

    % abc

    E +

    (a)=

    tests/test_myst_block.py:21: AssertionError ----------------------------------------------------------------------------------- Captured stdout call ------------------------------------------------------------------------------------

    +++

    % abc

    (a)=

    ================================================================================== short test summary info ================================================================================== FAILED tests/test_admon.py::test_all[306-Indented by 4 spaces, DISABLE-CODEBLOCKS- ??? note\n content\n-
    \n

    Note

    \n

    content

    \n
    \n] - assert '

    ??? note\ncontent

    ' == '
    \n\\begin{equation}\n a = 1\n \\end{equation}\n
    \n] - assert '

    \\begin{e...equation}

    ' == '
    head\n] - assert '

    {#a .a b=c}\n# head

    ' == '

    head

    ' FAILED tests/test_colon_fence.py::test_fixtures[438-Indented by 4 spaces, DISABLE-CODEBLOCKS- :::name\n foo\n :::\n-
    foo\n
    \n] - assert '

    :::name\nfoo\n:::

    ' == '
    ' FAILED tests/test_container.py::test_all[301-Indented by 4 spaces, DISABLE-CODEBLOCKS- ::: name\n content\n :::\n-
    \n

    content

    \n
    \n] - assert '

    ::: name\...tent\n:::

    ' == '
    \na\n
    \n] - assert '

    a

    ' == '
    \na\n
    ' FAILED tests/test_field_list.py::test_all[378-Indented_by_4_spaces,_DISABLE-CODEBLOCKS] - assert '

    :name: text\nindented

    ' == '
    [1]

    \n
    \n
    \n
      \n
    1. footnote \u21a9\ufe0e

      \n
    2. \n
    \n
    \n] - assert '

    [^1]

    \... footnote

    ' == '

    \n

' FAILED tests/test_myst_block.py::test_all[168-Indented by 4 spaces, DISABLE-CODEBLOCKS- +++\n\n % abc\n\n (a)=\n-
\n\n] - assert '

+++

\n...\n

(a)=

' == '
eamanu commented 1 year ago

Hi @kloczek, same issue in Debian. Please see #92

chrisjsewell commented 2 months ago

I'm afraid the tests are not intended for end users, there is no guarantee they work outside of this repository and its CLI/dev setup

kloczek commented 2 months ago

Packagers are not end users.

chrisjsewell commented 2 months ago

Packagers are not end users.

This package is written and distributed for users, not packagers. If you do not want to package it because of the limitations I would understand and encourage you not to

kloczek commented 2 months ago

You are forgetting that currently almost none od the end users is using self build and installed software.

So what what is wrong in this case that pytest fails? 🤔

chrisjsewell commented 2 months ago

You are forgetting that currently almost none od the end users is using self build and installed software.

No they are using wheel installs from pypi, using pip or uv, this is the only way I recommend using python packages, and the only focus of support.

The only stipulation on the tests is that they work in the CI, nothing more

kloczek commented 2 months ago

No they are using wheel installs from pypi, using pip or uv, this is the only way I recommend using python packages, and the only focus of support.

Really? Basing on what you are claiming that? 🤔

chrisjsewell commented 2 months ago

Basing on what you are claiming that? 🤔

The 1 million downloads per day from pypi https://pypistats.org/packages/mdit-py-plugins

But look this is not a debate, I'm just doing you the courtesy of letting you know the priority for this repository and in fact for every python package I author/maintain (and has always been).

This is open source software, free, there is no obligation on my part to do anything; if this is not to your taste, you are absolutely welcome to not use it, or to fork it, the choice is yours

kloczek commented 2 months ago

The 1 million downloads per day from pypi https://pypistats.org/packages/mdit-py-plugins

Please try to look on those data closer. Most of the downloads are for python version no longer supported by and/or any latest version of any Linux/BSD/Solaris/Win distributions. Those people have no choice ..