Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
60f205f
WIP on doctests
janbridley Jan 15, 2025
474d8eb
Add sphinx-copybutton and notfound
janbridley Jan 15, 2025
1b8d934
messy wip on sybil
janbridley Jan 15, 2025
6ec1619
Further wip
janbridley Jan 15, 2025
f22e876
Remove .doctrees
janbridley Jan 15, 2025
90cd64a
Remove CIFTEST
janbridley Jan 15, 2025
8ed9575
Swap to pytest-doctestplus
janbridley Jan 15, 2025
6511b22
Remove unused files
janbridley Jan 15, 2025
186148b
Clean up settings
janbridley Jan 15, 2025
9cbd851
Fix read_cell_params interaction with cast_values
janbridley Jan 15, 2025
445f199
Clean up conf.py
janbridley Jan 15, 2025
a3c17f2
Update filepath for docstrings
janbridley Jan 15, 2025
3e18f34
Clean up pyproject.toml
janbridley Jan 15, 2025
1c89cfa
Fix formatting for doctests
janbridley Jan 15, 2025
2640240
Finalize indentation for quickstart.rst
janbridley Jan 15, 2025
9b8a429
Update requirements.in files
janbridley Jan 15, 2025
ae30d9c
Update doc/requirements.txt
janbridley Jan 15, 2025
a4ed0ae
Update requirements files
janbridley Jan 15, 2025
49efea4
Fix return None example
janbridley Jan 15, 2025
38fcb7b
Lint
janbridley Jan 15, 2025
eb9ec19
Fix pytest-doctestplus version
janbridley Jan 15, 2025
22ceb58
Update `cell` to return box-like
janbridley Jan 16, 2025
6837f40
Clarify docs for CifFile.cell
janbridley Jan 16, 2025
0dfb7d4
Final cleanup of freud tests
janbridley Jan 16, 2025
170c986
Install freud on ubuntu-latest tests
janbridley Jan 16, 2025
d2b5fc4
Add missing doctest: +SKIP
janbridley Jan 16, 2025
bfa08da
Use pytest importorskip
janbridley Jan 16, 2025
959f3df
Remove freud from ci
janbridley Jan 16, 2025
a049245
Fix doctest-requires block
janbridley Jan 16, 2025
7ae4ff4
Standardize spelling of angstrom
janbridley Jan 16, 2025
7331d04
Rename cell to box
janbridley Jan 16, 2025
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
Prev Previous commit
Next Next commit
Swap to pytest-doctestplus
  • Loading branch information
janbridley committed Jan 15, 2025
commit 8ed957586f3b5d61c491f7c1007326474cb8d50a
56 changes: 28 additions & 28 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# Copyright (c) 2024, Glotzer Group
# This file is from the parsnip project, released under the BSD 3-Clause License.
# # Copyright (c) 2024, Glotzer Group
# # This file is from the parsnip project, released under the BSD 3-Clause License.

import doctest
# import doctest

import pytest
from sybil import Sybil
from sybil.parsers.doctest import DocTestParser
from sybil.parsers.rest import DocTestDirectiveParser
# import pytest
# from sybil import Sybil
# from sybil.parsers.doctest import DocTestParser
# from sybil.parsers.rest import DocTestDirectiveParser

DOCTEST_OPTIONFLAGS = (
doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL | doctest.ELLIPSIS
)
# DOCTEST_OPTIONFLAGS = (
# doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL | doctest.ELLIPSIS
# )

@pytest.fixture(scope="module")
def changedir():
import os
cwd = os.getcwd()
try:
os.chdir("doc/source")
finally:
os.chdir(cwd)
# @pytest.fixture(scope="module")
# def changedir():
# import os
# cwd = os.getcwd()
# try:
# os.chdir("doc/source")
# finally:
# os.chdir(cwd)

pytest_collect_file = Sybil(
parsers=[
DocTestParser(optionflags=DOCTEST_OPTIONFLAGS),
# DocTestDirectiveParser(optionflags=DOCTEST_OPTIONFLAGS)
# DocTestParser(optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS)
],
pattern="*.rst",
path="doc/source",
fixtures=['changedir']
).pytest()
# pytest_collect_file = Sybil(
# parsers=[
# DocTestParser(optionflags=DOCTEST_OPTIONFLAGS),
# # DocTestDirectiveParser(optionflags=DOCTEST_OPTIONFLAGS)
# # DocTestParser(optionflags=doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS)
# ],
# pattern="*.rst",
# path="doc/source",
# fixtures=['changedir']
# ).pytest()
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx_copybutton",
# "pytest_doctestplus.sphinx.doctestplus",
"pytest_doctestplus.sphinx.doctestplus",
"autodocsumm",
"notfound.extension"
]
Expand Down
12 changes: 5 additions & 7 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ Now, let's read extract the key-value pairs from our cif file. This subset of da
usually contains information to reconstruct the system's unit cell, and provides
information regarding the origin of the data.

.. invisible-code-block:

from parsnip import CifFile
filename = "example_file.cif"
cif = CifFile(filename)
.. testsetup::

>>> import os
>>> os.chdir("doc/source")

.. doctest::

>>> from parsnip import CifFile
>>> filename = "doc/source/example_file.cif" # TODO: fix filename
>>> filename = "example_file.cif"
>>> cif = CifFile(filename)

>>> cif.pairs
Expand Down Expand Up @@ -129,7 +127,7 @@ convenient.
array([['0.0000000000', '0.0000000000', '0.0000000000']], dtype='<U12')

>>> xyz.astype(float)
array([[0.0, 0.0, 0.0]], dtype=np.float64)
array([[0., 0., 0.]])



Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ optional-dependencies = {tests = { file = ["tests/requirements.in"] }, doc = { f
# testpaths = ["doc", "tests", "parsnip"]
testpaths = ["doc"]
console_output_style = "progress"
# addopts = ["--doctest-plus", "--doctest-glob='*.rst'"]
addopts = ["-p no:doctest"]
# doctest_rst = true
# doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS", "FLOAT_CMP", "REPORT_CDIFF"]
addopts = ["--doctest-plus", "--doctest-glob='*.rst'"]
# addopts = ["-p no:doctest"]
doctest_rst = true
doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS", "FLOAT_CMP", "REPORT_CDIFF"]
# doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS"]

[tool.ruff]
Expand Down