pypa / readme_renderer

Safely render long_description/README files in Warehouse
Apache License 2.0
158 stars 88 forks source link

32.0: pytest warnings #222

Closed kloczek closed 1 year ago

kloczek commented 2 years ago

Looks like pytest shows few warnings

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-readme_renderer-32.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-readme_renderer-32.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0, configfile: pytest.ini
plugins: anyio-3.3.4, tornasync-0.6.0.post2, cov-3.0.0, httpbin-1.0.1, socket-0.5.0
collected 28 items

tests/test_clean.py .                                                                                                                                                [  3%]
tests/test_integration_distutils.py ......                                                                                                                           [ 25%]
tests/test_markdown.py s.                                                                                                                                            [ 32%]
tests/test_noextra.py ..                                                                                                                                             [ 39%]
tests/test_rst.py ................                                                                                                                                   [ 96%]
tests/test_txt.py .                                                                                                                                                  [100%]

============================================================================= warnings summary =============================================================================
readme_renderer/markdown.py:44
  /home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/readme_renderer/markdown.py:44: UserWarning: Markdown renderers are not available. Install 'readme_renderer[md]' to enable Markdown rendering.
    warnings.warn(_EXTRA_WARNING)

tests/test_markdown.py::test_missing_variant
  /home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/readme_renderer/markdown.py:56: UserWarning: Markdown renderers are not available. Install 'readme_renderer[md]' to enable Markdown rendering.
    warnings.warn(_EXTRA_WARNING)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/test_markdown.py:23: got empty parameter set ('md_filename', 'html_filename', 'variant'), function test_md_fixtures at /home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/test_markdown.py:22
================================================================ 27 passed, 1 skipped, 2 warnings in 1.07s ===============================================================
di commented 2 years ago

These tests are explicitly testing that these warnings are raised: https://github.com/pypa/readme_renderer/blob/6a9b282823e033d4344ca519452c49def6d259ec/tests/test_noextra.py

I'm not sure there's a way to suppress them from being surfaced by pytest.

I'm more concerned about the skipped test, is your distribution of readme_renderer missing the test fixtures?

kloczek commented 2 years ago

These tests are explicitly testing that these warnings are raised

Ah .. so there is nothing to do here 😄 Thank you to let me know. I'm closing this ticket.

di commented 2 years ago

I'm more concerned about the skipped test, is your distribution of readme_renderer missing the test fixtures?

Did you see this?

kloczek commented 2 years ago

I'm not sure what it it means. Can you explain that shortly?

di commented 2 years ago

That test depends on the files in https://github.com/pypa/readme_renderer/tree/main/tests/fixtures being present. It appears that the test was skipped because none of these files are present in the environment in which you ran these tests.

kloczek commented 2 years ago

As input resource I'm using autogenerated tar ball from git tag. https://github.com/pypa/readme_renderer/archive/32.0/python-readme_renderer-32.0.tar.gz That tar ball contais tests/fixture/ directory.

di commented 2 years ago

@kloczek What's the output of the following command in the root of that tarball?

$ python -c "from tests.test_markdown import MD_FIXTURES; print(MD_FIXTURES)"

If that's empty, what's the following:

$ python -c 'from tests.test_markdown import __file__; import glob; import os; print(list(glob.iglob(os.path.join(os.path.dirname(__file__), "fixtures", "test_GFM*.md"))))'

And if that's empty, what's this?

$ python -c 'from tests.test_markdown import __file__; import os; print(os.path.join(os.path.dirname(__file__), "fixtures"))'
kloczek commented 2 years ago

@kloczek What's the output of the following command in the root of that tarball?

$ python -c "from tests.test_markdown import MD_FIXTURES; print(MD_FIXTURES)"
/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/readme_renderer/markdown.py:44: UserWarning: Markdown renderers are not available. Install 'readme_renderer[md]' to enable Markdown rendering.
warnings.warn(_EXTRA_WARNING)
[]

If that's empty, what's the following:

$ python -c 'from tests.test_markdown import __file__; import glob; import os; print(list(glob.iglob(os.path.join(os.path.dirname(__file__), "fixtures", "test_GFM*.md"))))'
/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/readme_renderer/markdown.py:44: UserWarning: Markdown renderers are not available. Install 'readme_renderer[md]' to enable Markdown rendering.
warnings.warn(_EXTRA_WARNING)
['/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_001.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_002.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_003.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_004.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_005.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_006.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_007.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_008.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_009.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_010.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_011.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_012.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_013.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_014.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_015.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_016.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_017.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_018.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_019.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_020.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_021.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_022.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_023.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_024.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_025.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_doublequotes.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_highlight.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_highlight_default_py.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_img.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_malicious_pre.md', '/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures/test_GFM_style.md']

And if that's empty, what's this?

$ python -c 'from tests.test_markdown import __file__; import os; print(os.path.join(os.path.dirname(__file__), "fixtures"))'

It is not empty however just FTR result

/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/readme_renderer/markdown.py:44: UserWarning: Markdown renderers are not available. Install 'readme_renderer[md]' to enable Markdown rendering.
warnings.warn(_EXTRA_WARNING)
/home/tkloczko/rpmbuild/BUILD/readme_renderer-32.0/tests/fixtures
di commented 2 years ago

Got it. Looks like you're testing this without the optional cmarkgfm dependency:

https://github.com/pypa/readme_renderer/blob/f96ab230fcd4fb92e48be897320bbdcd1f0a0ffc/setup.py#L62

How does your redistributing handle these 'extra' dependencies?

kloczek commented 2 years ago

How does your redistributing handle these 'extra' dependencies?

Generally speaking as I'm packaging readme_renderer as rpm package all depends on manually specified BuidRequires. OK. Will try to add that module to build env 😄

miketheman commented 2 years ago

@kloczek Did you figure this out? If so, feel free to close the issue!

kloczek commented 2 years ago

Still I have the same warnings ..

miketheman commented 2 years ago

I don't think we have enough details to effectively assist here, as we don't have information as to how you're packaging this code, so can't reproduce.

Can you share more on how we could reproduce this issue to try and resolve?

kloczek commented 2 years ago

What kind of details you need?

miketheman commented 2 years ago

Maybe for starters, what commands and environment you’re using to run this rpm build? StackOverflow has a good article on what to provide for reproduction: https://stackoverflow.com/help/minimal-reproducible-example

kloczek commented 2 years ago

I'm using pep517 based buid:

Here it is list of modules installd in build env

Package         Version
--------------- --------------
attrs           22.1.0.dev0
bleach          5.0.0
Brlapi          0.8.3
build           0.8.0
codespell       2.1.0
cycler          0.11.0
distro          1.7.0
docutils        0.17.1
extras          1.0.0
fixtures        4.0.0
fonttools       4.33.3
gpg             1.17.1-unknown
html5lib        1.1
iniconfig       1.1.1
kiwisolver      1.4.3
libcomps        0.1.18
louis           3.22.0
matplotlib      3.5.2
numpy           1.23.0
olefile         0.46
packaging       21.3
pbr             5.8.1
pep517          0.12.0
Pillow          9.1.1
pip             22.0.4
pluggy          1.0.0
py              1.11.0
Pygments        2.12.0
PyGObject       3.42.1
pyparsing       3.0.9
pytest          7.1.2
python-dateutil 2.8.2
rpm             4.17.0
setuptools      62.6.0
six             1.16.0
testtools       2.5.0
tomli           2.0.1
webencodings    0.5.1
wheel           0.37.1
miketheman commented 2 years ago

Thanks for the details.

I think the crux of this issue, as @di pointed out earlier, is that you're missing the extras dependency of cmarkgfm which would then execute more of the test suite. It's a runtime dependency, and will produce end-user warnings of the package isn't present, and the test suite confirms that.

You haven't provided how the build tool dependencies are installed, nor the library dependencies, nor the pytest dependency that is then invoked. In your list of dependencies, the install_requires ones are present, which is as intended.

My current read on this is that it comes down to how your unique build environment is being set up - and not about the package and dependencies.