Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sphinx-notes/cookiecutter",
"commit": "634c4022e575bd086ea47f3b42feafe24e14a939",
"commit": "62cd96195962da3392cdc34125c95e9144a5f5ca",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -20,7 +20,7 @@
"sphinx_version": "7.0",
"development_status": "3 - Alpha",
"_template": "https://github.com/sphinx-notes/cookiecutter",
"_commit": "634c4022e575bd086ea47f3b42feafe24e14a939"
"_commit": "62cd96195962da3392cdc34125c95e9144a5f5ca"
}
},
"directory": null
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- run: python3 -m pip install .[dev]
- run: python3 -m pip install .[test]
- run: make test
doctest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v5
with:
python-version-file: 'pyproject.toml'
- run: python3 -m pip install .[docs]
- run: make doctest
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ fmt:

.PHONY: test
test:
$(PY) -m unittest discover -s tests -v
$(PY) -m pytest tests/ -v

.PHONY: doctest
doctest:
$(MAKE) doctest -C docs/

################################################################################
# Distribution Package
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# ones.
extensions = [
'sphinx.ext.githubpages',
'sphinx.ext.doctest',
'sphinx_design',
'sphinx_copybutton',
'sphinx_last_updated_by_git',
Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pathlib import Path
import pytest

pytest_plugins = 'sphinx.testing.fixtures'

@pytest.fixture(scope='session')
def rootdir() -> Path:
return Path(__file__).parent / 'roots'
1 change: 1 addition & 0 deletions tests/roots/test-smoke/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions = ['sphinxnotes.data']
15 changes: 15 additions & 0 deletions tests/roots/test-smoke/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Smoke Test
==========

.. data:template::

Name: **{{ name }}**
{% for k, v in attrs.items() %}
{{ k }}: {{ v }}
{% endfor %}

.. data:define:: Test User
:homepage: https://example.com/
:email: test@example.com

This is a test user.
9 changes: 9 additions & 0 deletions tests/test_always_pass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file is generated from sphinx-notes/cookiecutter.
# DO NOT EDIT.

import unittest


class TestAlwaysPass(unittest.TestCase):
def test_dummy(self):
self.assertTrue(True)
27 changes: 27 additions & 0 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Smoke tests for sphinxnotes.data extension."""

import pytest

PHASES = ['parsing', 'parsed', 'resolving']


@pytest.mark.sphinx('html', testroot='smoke')
@pytest.mark.parametrize('phase', PHASES)
def test_data_template_and_define(app, status, warning, phase):
"""Test that data:template and data:define directives work correctly."""
index_path = app.srcdir / 'index.rst'
content = index_path.read_text(encoding='utf-8')
modified_content = content.replace(
'.. data:template::',
f'.. data:template::\n :on: {phase}',
1,
)
index_path.write_text(modified_content, encoding='utf-8')

app.build()

html = (app.outdir / 'index.html').read_text(encoding='utf-8')

assert 'Test User' in html
assert 'https://example.com/' in html
assert 'test%40example.com' in html