Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] add a line matcher object #12219

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
30a4671
enhance ANSI functions
picnixz Mar 30, 2024
45ea39b
remove ``# type: ignore[attr-defined]`` for colors
picnixz Mar 30, 2024
86c3efe
add tests for ANSI strippers
picnixz Mar 30, 2024
55099de
add matcher objects for tests
picnixz Mar 29, 2024
0fe03c0
enhance ANSI functions
picnixz Mar 30, 2024
2c1df50
remove ``# type: ignore[attr-defined]`` for colors
picnixz Mar 30, 2024
73f3d88
add tests for ANSI strippers
picnixz Mar 30, 2024
d4a277b
Merge branch 'fix/ansi-functions' into feat/line-matcher
picnixz Mar 31, 2024
fb92ab5
update
picnixz Mar 31, 2024
f4309fb
cleanup
picnixz Mar 31, 2024
b9ce7ec
split tests and utils into modules
picnixz Mar 31, 2024
6972a22
Merge remote-tracking branch 'upstream/master' into fix/ansi-functions
picnixz Apr 1, 2024
c48e6ac
Merge branch 'fix/ansi-functions' into feat/line-matcher
picnixz Apr 1, 2024
4c3566a
add explicit ``typing-extensions`` dependency
picnixz Apr 1, 2024
bef6b17
cleanup
picnixz Apr 1, 2024
bf8de84
fixup
picnixz Apr 1, 2024
9fd372a
Update documentation and make buffers more efficient.
picnixz Apr 1, 2024
5232421
fix various bugs
picnixz Apr 2, 2024
3695617
fixup
picnixz Apr 2, 2024
c8cb941
fix bugs
picnixz Apr 2, 2024
83b5003
fix bugs
picnixz Apr 2, 2024
7edf273
simplify ANSI handling
picnixz Apr 2, 2024
dc37de5
remove complicated stuff
picnixz Apr 2, 2024
7ce24f3
fixup
picnixz Apr 2, 2024
846edef
fixup
picnixz Apr 2, 2024
136ac66
fixup
picnixz Apr 3, 2024
5b49b41
Merge branch 'fix/ansi-functions' into feat/line-matcher
picnixz Apr 3, 2024
c3d4405
fix bug
picnixz Apr 3, 2024
c2d5c15
improve coverage
picnixz Apr 3, 2024
d4fb7b9
fixup
picnixz Apr 3, 2024
1250ac9
fixup
picnixz Apr 3, 2024
6cc70a6
fixup
picnixz Apr 3, 2024
70f232d
explain ``__tracebackhide__`` flag
picnixz Apr 3, 2024
7e9fa1a
set default options
picnixz Apr 3, 2024
594b0cd
update docs + option names
picnixz Apr 3, 2024
72d7c18
Merge branch 'master' into feat/line-matcher
picnixz Apr 4, 2024
c1707f0
cleanup
picnixz Apr 4, 2024
974d39b
remove unused methods
picnixz Apr 4, 2024
df7496a
add tests for options
picnixz Apr 4, 2024
4574410
cleanup
picnixz Apr 4, 2024
3fec5a8
cleanup
picnixz Apr 4, 2024
e6ac4a9
cleanup
picnixz Apr 4, 2024
dd2d267
cleanup
picnixz Apr 4, 2024
5afea2b
Merge branch 'master' into feat/line-matcher
picnixz Apr 5, 2024
bc20703
fixup
picnixz Apr 5, 2024
a543021
fixup
picnixz Apr 5, 2024
6ed1e4e
Merge branch 'master' into feat/line-matcher
picnixz Apr 5, 2024
fb95a6e
improve coverage
picnixz Apr 5, 2024
c9c6888
Update doc
picnixz Apr 5, 2024
bb5cb11
Update doc
picnixz Apr 5, 2024
173076d
Update doc
picnixz Apr 5, 2024
e1a412f
fix ref
picnixz Apr 5, 2024
c6b97fb
fix typos
picnixz Apr 5, 2024
fd84ef3
cleanup
picnixz Apr 6, 2024
a533d14
micro optimizations
picnixz Apr 6, 2024
d759057
[search] fix an undefined local variable (#12235)
picnixz Apr 6, 2024
1cbec31
doc and implementation details improvements
picnixz Apr 7, 2024
0eb6639
cleanup
picnixz Apr 8, 2024
ec2dd0f
cleanup
picnixz Apr 8, 2024
bd91c1c
Merge branch 'master' into feat/line-matcher
picnixz Apr 10, 2024
5752a51
revert
picnixz Apr 10, 2024
0b0b5a1
fixup
picnixz Apr 10, 2024
f66885c
Merge branch 'master' into feat/line-matcher
picnixz Apr 15, 2024
310f589
Merge branch 'master' into feat/line-matcher
picnixz Apr 19, 2024
b85e80a
cleanup
picnixz Apr 19, 2024
5a2d07b
Merge branch 'master' into feat/line-matcher
picnixz Apr 27, 2024
488343f
Update test_matcher_buffer.py
picnixz Apr 27, 2024
b3967c4
Update test_matcher_cleaner.py
picnixz Apr 27, 2024
dbeba16
Update test_matcher_buffer.py
picnixz Apr 27, 2024
963c4ce
Update __init__.py
picnixz Apr 27, 2024
810ca5a
improve python-code roles
picnixz Apr 28, 2024
843e0c7
simplify op-codes logic
picnixz Apr 28, 2024
35673f0
use type aliases
picnixz Apr 28, 2024
6c50e61
changed 'none' flavor to 'literal'
picnixz Apr 28, 2024
acdc53f
Update API according to comments
picnixz Apr 28, 2024
35fe86b
update tests
picnixz Apr 28, 2024
466bcc3
remove unused code
picnixz Apr 28, 2024
1e2cf99
Merge branch 'master' into feat/line-matcher
picnixz May 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 24 additions & 1 deletion doc/conf.py
@@ -1,11 +1,16 @@
# Sphinx documentation build configuration file
from __future__ import annotations

import os
import re
import time
from typing import TYPE_CHECKING

import sphinx

if TYPE_CHECKING:
from sphinx.application import Sphinx

os.environ['SPHINX_AUTODOC_RELOAD_MODULES'] = '1'

extensions = [
Expand Down Expand Up @@ -208,6 +213,13 @@
('py:class', 'sphinx.theming.Theme'),
('py:class', 'sphinxcontrib.websupport.errors.DocumentNotFoundError'),
('py:class', 'sphinxcontrib.websupport.errors.UserNotAuthorizedError'),
# stdlib
('py:class', '_io.StringIO'),
('py:class', 'typing_extensions.Self'),
('py:class', 'typing_extensions.Unpack'),
# type variables
('py:class', 'sphinx.testing.matcher.buffer.T'),
('py:class', 'sphinx.testing.matcher.options.DT'),
('py:exc', 'docutils.nodes.SkipNode'),
('py:exc', 'sphinx.environment.NoUri'),
('py:func', 'setup'),
Expand Down Expand Up @@ -274,8 +286,9 @@ def linkify(match):
source[0] = source[0].replace('.. include:: ../CHANGES.rst', linkified_changelog)


def setup(app):
def setup(app: Sphinx) -> None:
from sphinx.ext.autodoc import cut_lines
from sphinx.roles import code_role
from sphinx.util.docfields import GroupedField

app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
Expand All @@ -290,3 +303,13 @@ def setup(app):
app.add_object_type(
'event', 'event', 'pair: %s; event', parse_event, doc_field_types=[fdesc]
)

def pycode_role(name, rawtext, text, lineno, inliner, options=None, content=()):
options = (options or {}) | {'language': 'python'}
return code_role(name, rawtext, text, lineno, inliner, options, content)

def pyrepr_role(name, rawtext, text, lineno, inliner, options=None, content=()):
return pycode_role(name, rawtext, repr(text), lineno, inliner, options, content)

app.add_role('py3', pycode_role)
app.add_role('py3repr', pyrepr_role)
1 change: 1 addition & 0 deletions doc/development/index.rst
Expand Up @@ -15,6 +15,7 @@ the extension interface see :doc:`/extdev/index`.
overview
tutorials/index
builders
testing/index

.. toctree::
:caption: Theming
Expand Down
15 changes: 15 additions & 0 deletions doc/development/testing/index.rst
@@ -0,0 +1,15 @@
=======
Testing
=======

The :mod:`!sphinx.testing` module provides utility classes, functions, fixtures
and markers for testing with `pytest`_. Refer to the following sections to get
started with testing integration.

.. toctree::
:maxdepth: 1

plugin
matcher

.. _pytest: https://docs.pytest.org/en/latest/
23 changes: 23 additions & 0 deletions doc/development/testing/matcher.rst
@@ -0,0 +1,23 @@
Testing the Sphinx output
=========================

.. automodule:: sphinx.testing.matcher
:members:
:member-order: bysource

.. automodule:: sphinx.testing.matcher.options
:members:
:member-order: bysource

.. automodule:: sphinx.testing.matcher.buffer
:members:
:member-order: bysource

Utility functions
-----------------

.. automodule:: sphinx.testing.matcher.cleaner
:members:
:member-order: bysource
:ignore-module-all:

19 changes: 19 additions & 0 deletions doc/development/testing/plugin.rst
@@ -0,0 +1,19 @@
The Sphinx testing plugin
=========================

The testing plugin can be enabled by adding following line in ``conftest.py``:

.. code-block:: python
:caption: conftest.py

pytest_plugins = ['sphinx.testing.fixtures']

This rest of the section is dedicated to documenting the testing features but
the reader is assumed to have some prior knowledge on `pytest`_.

.. warning::

This topic is incomplete and some features are not yet documented.

.. _pytest: https://docs.pytest.org/en/latest/

2 changes: 2 additions & 0 deletions pyproject.toml
Expand Up @@ -80,6 +80,7 @@ dynamic = ["version"]
[project.optional-dependencies]
docs = [
"sphinxcontrib-websupport",
"typing-extensions",
]
lint = [
"flake8>=3.5.0",
Expand All @@ -88,6 +89,7 @@ lint = [
"sphinx-lint",
"types-docutils",
"types-requests",
"typing-extensions",
"importlib_metadata", # for mypy (Python<=3.9)
"tomli", # for mypy (Python<=3.10)
"pytest>=6.0",
Expand Down