twisted / pydoctor

This is pydoctor, an API documentation generator that works by static analysis.
https://pydoctor.readthedocs.io
Other
179 stars 48 forks source link

Failing and undocumented test "test_pyval_repr.py::test_expressions_parens" #754

Closed buhtz closed 6 months ago

buhtz commented 6 months ago

Related to PR #722. I have a failing test for unknown reasons.

The problem is that the test is not documented. There is not doc string. It is unclear what happens in their. It also seems it is a pytest-style-test which is hard to read. I can not identify the "system under test" and I don't see the assert-check.

https://github.com/twisted/pydoctor/blob/662eafaedcdfcfa0c5a83c1048c28f187fbcf4c9/pydoctor/test/epydoc/test_pyval_repr.py#L1508

The full output:

$ pytest pydoctor/test/epydoc/test_pyval_repr.py::test_expressions_parens -vsx
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.9.2, pytest-7.4.2, pluggy-1.3.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/home/user/ownCloud/my.work/pydoctor/.hypothesis/examples'))
rootdir: /home/user/ownCloud/my.work/pydoctor
configfile: setup.cfg
plugins: hypothesis-6.92.2, pyfakefs-5.2.4
collected 1 item                                                                                                                                                                            

pydoctor/test/epydoc/test_pyval_repr.py::test_expressions_parens ERRORClearing the cache

========================================================================================== ERRORS ===========================================================================================
_________________________________________________________________________ ERROR at setup of test_expressions_parens _________________________________________________________________________
file /home/user/ownCloud/my.work/pydoctor/pydoctor/test/epydoc/test_pyval_repr.py, line 1508
  def test_expressions_parens(subtests:Any) -> None:
E       fixture 'subtests' not found
>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, fs, fs_class, fs_module, fs_session, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
>       use 'pytest --fixtures [testpath]' for help on them.

/home/user/ownCloud/my.work/pydoctor/pydoctor/test/epydoc/test_pyval_repr.py:1508
================================================================================== short test summary info ==================================================================================
ERROR pydoctor/test/epydoc/test_pyval_repr.py::test_expressions_parens
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 0.54s ======================================================================================

I do use pytest only as a front end to regular python vanilla unitest tests. A "fixture" is missing. How to solve this? To my very limited pytest knowledge a fixture is a hidden (decorator) function or method. Am I right so far?

The output of seems to be a list of "fixtures" and some error messages.

$ pytest --fixtures [testpath]
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.9.2, pytest-7.4.2, pluggy-1.3.0
rootdir: /home/user/ownCloud/my.work/pydoctor
configfile: setup.cfg
plugins: hypothesis-6.92.2, pyfakefs-5.2.4
collected 1331 items / 3 errors                                                                                                                                                                                   
cache -- .../_pytest/cacheprovider.py:532
    Return a cache object that can persist state between testing sessions.

capsysbinary -- .../_pytest/capture.py:1001
    Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.

capfd -- .../_pytest/capture.py:1029
    Enable text capturing of writes to file descriptors ``1`` and ``2``.

capfdbinary -- .../_pytest/capture.py:1057
    Enable bytes capturing of writes to file descriptors ``1`` and ``2``.

capsys -- .../_pytest/capture.py:973
    Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.

doctest_namespace [session scope] -- .../_pytest/doctest.py:757
    Fixture that returns a :py:class:`dict` that will be injected into the
    namespace of doctests.

pytestconfig [session scope] -- .../_pytest/fixtures.py:1353
    Session-scoped fixture that returns the session's :class:`pytest.Config`
    object.

record_property -- .../_pytest/junitxml.py:282
    Add extra properties to the calling test.

record_xml_attribute -- .../_pytest/junitxml.py:305
    Add extra xml attributes to the tag for the calling test.

record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
    Record a new ``<property>`` tag as child of the root ``<testsuite>``.

tmpdir_factory [session scope] -- .../_pytest/legacypath.py:302
    Return a :class:`pytest.TempdirFactory` instance for the test session.

tmpdir -- .../_pytest/legacypath.py:309
    Return a temporary directory path object which is unique to each test
    function invocation, created as a sub directory of the base temporary
    directory.

caplog -- .../_pytest/logging.py:570
    Access and control log capturing.

monkeypatch -- .../_pytest/monkeypatch.py:30
    A convenient fixture for monkey-patching.

recwarn -- .../_pytest/recwarn.py:30
    Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.

tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:245
    Return a :class:`pytest.TempPathFactory` instance for the test session.

tmp_path -- .../_pytest/tmpdir.py:260
    Return a temporary directory path object which is unique to each test
    function invocation, created as a sub directory of the base temporary
    directory.

---------------------------------------------------------------------------------- fixtures defined from pyfakefs.pytest_plugin -----------------------------------------------------------------------------------
fs -- ../../../.local/lib/python3.9/site-packages/pyfakefs/pytest_plugin.py:31
    Fake filesystem.

fs_class [class scope] -- ../../../.local/lib/python3.9/site-packages/pyfakefs/pytest_plugin.py:44
    Class-scoped fake filesystem fixture.

fs_module [module scope] -- ../../../.local/lib/python3.9/site-packages/pyfakefs/pytest_plugin.py:56
    Module-scoped fake filesystem fixture.

fs_session [session scope] -- ../../../.local/lib/python3.9/site-packages/pyfakefs/pytest_plugin.py:68
    Session-scoped fake filesystem fixture.

--------------------------------------------------------------------------------- fixtures defined from pydoctor.test.test_sphinx ---------------------------------------------------------------------------------
inv_reader -- pydoctor/test/test_sphinx.py:58
    no docstring available

inv_reader_nolog -- pydoctor/test/test_sphinx.py:63
    no docstring available

cacheDirectory [module scope] -- pydoctor/test/test_sphinx.py:693
    no docstring available

inv_writer_nolog -- pydoctor/test/test_sphinx.py:81
    @return: A Sphinx inventory writer that is connected to a null logger.

-------------------------------------------------------------------------------- fixtures defined from pydoctor.test.test_options ---------------------------------------------------------------------------------
tempDir [module scope] -- pydoctor/test/test_options.py:139
    no docstring available

--------------------------------------------------------------------------------- fixtures defined from pydoctor.test.test_sphinx ---------------------------------------------------------------------------------
send_returns -- pydoctor/test/test_sphinx.py:588
    Return a function that patches
    L{requests.adapters.HTTPAdapter.send} so that it returns the
    provided L{requests.Response}.

--------------------------------------------------------------------------------- fixtures defined from pydoctor.test.test_utils ----------------------------------------------------------------------------------
setup -- pydoctor/test/test_utils.py:9
    CaseInsensitiveDict instance with "Accept" header.

Clearing the cache

===================================================================================================== ERRORS ======================================================================================================
_____________________________________________________________________________ ERROR collecting docs/tests/test_python_igraph_docs.py ______________________________________________________________________________
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
../../../.local/lib/python3.9/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
../../../.local/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
docs/tests/test_python_igraph_docs.py:10: in <module>
    BASE_DIR = get_toxworkdir_subdir('python-igraph-output')
docs/tests/__init__.py:7: in get_toxworkdir_subdir
    assert dir.exists(), f"Looks like {dir} not not exist!"
E   AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/python-igraph-output not not exist!
____________________________________________________________________________ ERROR collecting docs/tests/test_standard_library_docs.py ____________________________________________________________________________
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
../../../.local/lib/python3.9/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
../../../.local/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
docs/tests/test_standard_library_docs.py:10: in <module>
    PYTHON_DIR = get_toxworkdir_subdir('cpython')
docs/tests/__init__.py:7: in get_toxworkdir_subdir
    assert dir.exists(), f"Looks like {dir} not not exist!"
E   AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/cpython not not exist!
________________________________________________________________________________ ERROR collecting docs/tests/test_twisted_docs.py _________________________________________________________________________________
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
../../../.local/lib/python3.9/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
../../../.local/lib/python3.9/site-packages/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
../../../.local/lib/python3.9/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
../../../.local/lib/python3.9/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
../../../.local/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
docs/tests/test_twisted_docs.py:10: in <module>
    BASE_DIR = get_toxworkdir_subdir('twisted-apidocs-build')
docs/tests/__init__.py:7: in get_toxworkdir_subdir
    assert dir.exists(), f"Looks like {dir} not not exist!"
E   AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/twisted-apidocs-build not not exist!
============================================================================================= short test summary info =============================================================================================
ERROR docs/tests/test_python_igraph_docs.py - AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/python-igraph-output not not exist!
ERROR docs/tests/test_standard_library_docs.py - AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/cpython not not exist!
ERROR docs/tests/test_twisted_docs.py - AssertionError: Looks like /home/user/ownCloud/my.work/pydoctor/.tox/twisted-apidocs-build not not exist!
tristanlatr commented 6 months ago

Please use tox to run the tests. You are missing dependencies, that’s all.

buhtz commented 6 months ago

Please use tox to run the tests.

Information like this are belong into a CONTRIBUTE.md file. That is why I was asking.

You are missing dependencies, that’s all.

You are not very helpful. Please be more precise. What dependencies are missing? And I installed pydoctor (--editable) so there shouldn't be missing dependencies. If there are some you should fix the install/build part of pydoctor.

tristanlatr commented 6 months ago

I’ll close this issue since the tests is not actually broken, it’s just a matter of environment. I’ll open another issue to stop listing dependencies in the tox file. But unfortunately this is how we’ve been operating for quite some time now.