bskinn/sphobjinv

2.3: pytest is failing in two inits

Closed this issue · 8 comments

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 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-sphobjinv-2.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphobjinv-2.3-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.15, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sphobjinv-2.3, configfile: tox.ini
plugins: pytest_check-1.0.5
collected 760 items

README.rst F                                                                                                                                                         [  0%]
tests/test_api_fail.py ................................xxxx                                                                                                          [  4%]
tests/test_api_good.py ..............................................................................................................s.sssssssssssssssssssssssssssss [ 23%]
sssssssssssssssssssssssssssssss.sssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.                                                                         [ 35%]
tests/test_api_good_nonlocal.py sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss                                                                      [ 43%]
tests/test_cli.py ......s...s...s.........s.sssssssssssssssssssssssssssssssssssssssssssssssssssssssssss.............................                                 [ 58%]
tests/test_cli_nonlocal.py ssssssssssss                                                                                                                              [ 60%]
tests/test_fixture.py .....                                                                                                                                          [ 61%]
tests/test_flake8_ext.py s                                                                                                                                           [ 61%]
tests/test_intersphinx.py ....                                                                                                                                       [ 61%]
tests/test_readme.py F                                                                                                                                               [ 61%]
tests/test_valid_objects.py .............................................x........................x................................................................. [ 79%]
..........................................................................................................................................................           [100%]

================================================================================= FAILURES =================================================================================
___________________________________________________________________________ [doctest] README.rst ___________________________________________________________________________
149 JSON output is supported (``sphobjinv convert json ...``), and
150 inventories can be re-compressed to the
151 partially-zlib-compressed form that ``intersphinx`` reads
152 (``sphobjinv convert zlib ...``).
153
154 Alternatively, ``sphobjinv`` exposes an API to enable automation of
155 inventory creation/modification::
156
157     >>> import sphobjinv as soi
158     >>> inv = soi.Inventory('doc/build/html/objects.inv')
UNEXPECTED EXCEPTION: TypeError('Invalid Inventory source type')
Traceback (most recent call last):
  File "/usr/lib64/python3.8/doctest.py", line 1336, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest README.rst[1]>", line 1, in <module>
  File "<attrs generated init sphobjinv.inventory.Inventory>", line 16, in __init__
    self.__attrs_post_init__()
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-sphobjinv-2.3-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphobjinv/inventory.py", line 329, in __attrs_post_init__
    self._general_import()
  File "/home/tkloczko/rpmbuild/BUILDROOT/python-sphobjinv-2.3-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphobjinv/inventory.py", line 565, in _general_import
    raise TypeError("Invalid Inventory source type")
TypeError: Invalid Inventory source type
/home/tkloczko/rpmbuild/BUILD/sphobjinv-2.3/README.rst:158: UnexpectedException
__________________________________________________________________________ test_readme_shell_cmds __________________________________________________________________________
FAILURE:

  Expected:


      Project: sphobjinv
      Version: 2.3

      219 objects in inventory.

      11 results found at/above current threshold of 58.

      Cannot infer intersphinx_mapping from a local objects.inv.

        Name                                                Score
      ---------------------------------------------------  -------
      :py:property:`sphobjinv.data.SuperDataObj.as_rst`      60
      :py:class:`sphobjinv.cli.parser.PrsConst`              59
      :py:class:`sphobjinv.data.DataFields`                  59
      :py:class:`sphobjinv.data.DataObjBytes`                59
      :py:class:`sphobjinv.data.DataObjStr`                  59
      :py:class:`sphobjinv.data.SuperDataObj`                59
      :py:class:`sphobjinv.enum.HeaderFields`                59
      :py:class:`sphobjinv.enum.SourceTypes`                 59
      :py:function:`sphobjinv.fileops.writebytes`            59
      :py:function:`sphobjinv.fileops.writejson`             59
      :py:class:`sphobjinv.inventory.Inventory`              59


  Got:


  Error while parsing input file path:
  FileNotFoundError: Indicated path is not a valid file

assert False
 +  where False = <bound method OutputChecker.check_output of <doctest.OutputChecker object at 0x7f92779be1f0>>('\n\n    Project: sphobjinv\n    Version: 2.3\n\n    219 objects in inventory.\n\n    11 results found at/above curren...function:`sphobjinv.fileops.writejson`             59\n    :py:class:`sphobjinv.inventory.Inventory`              59\n', ' \n\nError while parsing input file path:\nFileNotFoundError: Indicated path is not a valid file\n', 12)
 +    where <bound method OutputChecker.check_output of <doctest.OutputChecker object at 0x7f92779be1f0>> = <doctest.OutputChecker object at 0x7f92779be1f0>.check_output
tests/test_readme.py:93 in test_readme_shell_cmds() -> assert chk.check_output(out, result, dt_flags), msg
FAILURE:

  Expected:

      Conversion completed.
      '...objects.inv' converted to '...objects.txt' (plain).


  Got:


  Error while parsing input file path:
  FileNotFoundError: Indicated path is not a valid file

assert False
 +  where False = <bound method OutputChecker.check_output of <doctest.OutputChecker object at 0x7f92779be1f0>>("\n    Conversion completed.\n    '...objects.inv' converted to '...objects.txt' (plain).\n", ' \n\nError while parsing input file path:\nFileNotFoundError: Indicated path is not a valid file\n', 12)
 +    where <bound method OutputChecker.check_output of <doctest.OutputChecker object at 0x7f92779be1f0>> = <doctest.OutputChecker object at 0x7f92779be1f0>.check_output
tests/test_readme.py:93 in test_readme_shell_cmds() -> assert chk.check_output(out, result, dt_flags), msg
------------------------------------------------------------
Failed Checks: 2
========================================================================= short test summary info ==========================================================================
SKIPPED [60] tests/test_api_good.py:499: '--testall' not specified
SKIPPED [60] tests/test_api_good.py:533: '--testall' not specified
SKIPPED [63] tests/test_api_good_nonlocal.py:48: '--nonloc' not specified
SKIPPED [3] tests/test_cli.py:124: Ignore no-change conversions
SKIPPED [60] tests/test_cli.py:226: '--testall' not specified
SKIPPED [12] tests/test_cli_nonlocal.py:57: '--nonloc' not specified
SKIPPED [1] tests/test_flake8_ext.py:50: '--flake8_ext' not specified
XFAIL tests/test_api_fail.py::TestImmutable::test_apifail_changing_immutable_dataobj[True-no_op]
  Made mutable to simplify Inventory revision by users
XFAIL tests/test_api_fail.py::TestImmutable::test_apifail_changing_immutable_dataobj[True-str]
  Made mutable to simplify Inventory revision by users
XFAIL tests/test_api_fail.py::TestImmutable::test_apifail_changing_immutable_dataobj[False-no_op]
  Made mutable to simplify Inventory revision by users
XFAIL tests/test_api_fail.py::TestImmutable::test_apifail_changing_immutable_dataobj[False-str]
  Made mutable to simplify Inventory revision by users
XFAIL tests/test_valid_objects.py::test_name_lead_chars[10_\n]
  reason: Known invalid name lead char
XFAIL tests/test_valid_objects.py::test_name_lead_chars[35_#]
  reason: Known invalid name lead char
FAILED README.rst::README.rst
FAILED tests/test_readme.py::test_readme_shell_cmds
========================================================== 2 failed, 493 passed, 259 skipped, 6 xfailed in 46.80s ==========================================================

Here is list of installed modules in build env

Package                       Version
----------------------------- -----------------
alabaster                     0.7.12
appdirs                       1.4.4
attrs                         22.1.0
Babel                         2.11.0
Brlapi                        0.8.3
build                         0.9.0
certifi                       2021.10.8
charset-normalizer            3.0.0
codespell                     2.2.1
contourpy                     1.0.5
cssselect                     1.1.0
cycler                        0.11.0
dictdiffer                    0.9.0
distro                        1.7.0
dnspython                     2.2.1
docutils                      0.18.1
extras                        1.0.0
fixtures                      4.0.0
fonttools                     4.38.0
fuzzywuzzy                    0.18.0
gpg                           1.17.1-unknown
idna                          3.4
imagesize                     1.4.1
importlib-metadata            5.0.0
importlib-resources           5.9.0
iniconfig                     1.1.1
Jinja2                        3.1.1
jsonschema                    4.17.0
kiwisolver                    1.4.4
libcomps                      0.1.19
louis                         3.23.0
lxml                          4.9.1
MarkupSafe                    2.1.1
matplotlib                    3.6.0
numpy                         1.23.1
olefile                       0.46
packaging                     21.3
pbr                           5.9.0
pep517                        0.13.0
Pillow                        9.2.0
pip                           22.2.2
pkgutil_resolve_name          1.3.10
pluggy                        1.0.0
py                            1.11.0
Pygments                      2.13.0
PyGObject                     3.42.2
pyparsing                     3.0.9
pyrsistent                    0.19.2
pytest                        7.1.3
pytest_check                  1.0.5
python-dateutil               2.8.2
pytz                          2022.4
requests                      2.28.1
rpm                           4.17.0
scour                         0.38.2
setuptools                    65.5.1
six                           1.16.0
snowballstemmer               2.2.0
Sphinx                        5.3.0
sphinx-issues                 3.0.1
sphinx-removed-in             0.2.1
sphinx-rtd-theme              1.1.0
sphinxcontrib-applehelp       1.0.2.dev20220730
sphinxcontrib-devhelp         1.0.2.dev20220730
sphinxcontrib-htmlhelp        2.0.0
sphinxcontrib-jsmath          1.0.1.dev20220730
sphinxcontrib-programoutput   0.17
sphinxcontrib-qthelp          1.0.3.dev20220730
sphinxcontrib-serializinghtml 1.1.5
stdio-mgr                     1.0.1
testtools                     2.5.0
tomli                         2.0.1
urllib3                       1.26.12
wheel                         0.37.1
zipp                          3.9.0

Did you build the docs first? The README tests will fail without a fresh build of the docs.

Alternatively, the README tests are cosmetic--you could just skip them with -k "not readme"

Did you build the docs first? The README tests will fail without a fresh build of the docs.

Without any problems.
Rendered man page during pytaest ecrcution is in build/sphinx/man.

Why testing README needs rendered documentation? 🤔

Because some examples in the README use the objects.inv from the built docs as their input.

The README tests are essentially doctests -- they enable me to be sure that the content in the README matches what the CLI and API actually output.

They have no bearing on the functionality of the package. Please just skip them with -k "not readme".

ok

Changed my mind -- it'll make my development flow better to pull these out of the main test suite. If I've done things right, you shouldn't have to deal with this for future sphobjinv releases.

OK. Thank you 👍
Do you want me to test that last pull/261?

Sure, might as well test it now.