Skip to content

Commit

Permalink
ci: run doctest in CI for Python API examples (delta-io#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
marijncv authored and ion-elgreco committed Nov 25, 2023
1 parent fe4fe51 commit c38b518
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
- name: Run tests
run: |
source venv/bin/activate
python -m pytest -m '((s3 or azure) and integration) or not integration and not benchmark'
python -m pytest -m '((s3 or azure) and integration) or not integration and not benchmark' --doctest-modules
- name: Test without pandas
run: |
Expand Down
2 changes: 1 addition & 1 deletion python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ check-python: ## Run check on Python
.PHONY: unit-test
unit-test: ## Run unit test
$(info --- Run Python unit-test ---)
python -m pytest
python -m pytest --doctest-modules

.PHONY: test-pyspark
test-pyspark:
Expand Down
20 changes: 20 additions & 0 deletions python/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import pathlib

import pytest


@pytest.fixture(autouse=True)
def doctest_setup(
request: pytest.FixtureRequest,
monkeypatch: pytest.MonkeyPatch,
tmp_path: pathlib.Path,
):
if isinstance(request.node, pytest.DoctestItem):
# disable color for doctests so we don't have to include
# escape codes in docstrings
monkeypatch.setitem(os.environ, "NO_COLOR", "1")
# Explicitly set the column width
monkeypatch.setitem(os.environ, "COLUMNS", "80")
# Work in a temporary directory
monkeypatch.chdir(str(tmp_path))
Loading

0 comments on commit c38b518

Please sign in to comment.