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

Reorganize the tests into unit/functional/integration/external #1155

Merged
merged 37 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2493743
Move the test notebooks to tests/data/notebooks
mwouts Nov 6, 2023
555d0d7
Move the pre-commit tests to a subdir
mwouts Nov 6, 2023
eb0e77e
Split tests into unit/integration/functional
mwouts Nov 7, 2023
2ef289a
Split the test dependencies into test/integration/functional
mwouts Nov 9, 2023
32f8c92
Document test requirements with pytest markers
mwouts Nov 11, 2023
c1850be
Use packaging.version if available
mwouts Nov 11, 2023
e22b7be
Ignore a few more warnings
mwouts Nov 11, 2023
c442e3f
Move the codecov.yml configuration file to .github
mwouts Nov 11, 2023
3fcc046
Remove the world population notebook from the examples
mwouts Nov 11, 2023
4b3eec3
Move some tests to external
mwouts Nov 19, 2023
bf6b3e4
Test unit/functional/integration/external tests and their dependencies
mwouts Nov 19, 2023
0b9344d
Parametrize the tests by all the Python files in `src/jupytext`
mwouts Nov 19, 2023
f180532
Move tests with dependencies to integration/external
mwouts Nov 19, 2023
3d5b528
Move test on pre-commit mode
mwouts Nov 19, 2023
ab15185
Label as external a test on the rst2md option
mwouts Nov 19, 2023
a6ca72d
Fix import error
mwouts Nov 19, 2023
4e32850
Include tests in the Jupytext package
mwouts Nov 19, 2023
4406786
Use Python 3.x for the external tests
mwouts Nov 19, 2023
57ed3b4
Filter more of the expected warnings
mwouts Nov 19, 2023
7442c15
Install JupyterLab before testing the extension
mwouts Nov 19, 2023
8f29535
Remove isort_version
mwouts Nov 19, 2023
674b3aa
Remove matrix.external, kernel=true is the default
mwouts Nov 19, 2023
54189af
Install external dependencies too
mwouts Nov 19, 2023
096ff0d
Install JupyterLab before running UI tests
mwouts Nov 19, 2023
abc6676
Fix name of env
mwouts Nov 19, 2023
3b82bdf
Restore environment-ci.yml
mwouts Nov 20, 2023
595e154
Include step test_classification in the CI
mwouts Nov 21, 2023
1417ca7
Remove empty line
mwouts Nov 21, 2023
a2cd5c7
Turn the tests notebooks into fixtures
mwouts Nov 21, 2023
23fdd2d
packaging is a dependency
mwouts Nov 23, 2023
12b2201
Importing parse won't fail
mwouts Nov 23, 2023
6e10678
Try codecov flags
mwouts Nov 23, 2023
6ea8a80
Remove marker 'requires_jupytext'
mwouts Nov 23, 2023
12dbf54
Simplify the pytest command
mwouts Nov 23, 2023
4fb0dba
Move some tests to external
mwouts Nov 23, 2023
3c8608d
Rename test to avoid conflict
mwouts Nov 23, 2023
52c53b1
Fix the tests on Windows
mwouts Nov 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 2 additions & 18 deletions .ci/environment-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# This environment is smaller than the dev environment.
#
# Until conda supports creating env from pyproject.toml
Expand All @@ -10,23 +11,6 @@ channels:
- defaults
- conda-forge
dependencies:
- ipykernel
- nbconvert
- jupyterlab
- nbformat>=5.1.2
- pyyaml
- toml
- markdown-it-py
- mdit-py-plugins
- pip
- pytest
- pytest-randomly
- pytest-cov
- coverage
- flake8
- autopep8
- black
- isort
- pandoc==2.16.2
- sphinx-gallery<0.8
- pre-commit
- gitpython
7 changes: 3 additions & 4 deletions codecov.yml → .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
codecov:
notify:
after_n_builds: 11
notify:
after_n_builds: 11

comment:
after_n_builds: 11

coverage:
status:
project:
default: false # disable the default status that measures entire project
tests:
paths:
- "tests/"
target: 100%
source:
paths:
- "jupytext/"
- "src/jupytext/"
target: 97%
threshold: 0.002
patch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/step_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
python -m pip install build wheel

# NOTE: These builds and verifications of the builds can be done more
# robustily with jupyter-releaser.
# robustly with jupyter-releaser.
#
# Removed the check on size of package as we are distributing tests/ with
# sdist now and they are around 8MB. Seems like original check was to make
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/step_tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
python-version: [ 3.9 ]
python-version: [ 3.11 ]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -38,9 +38,8 @@ jobs:
use-only-tar-bz2: true

- name: Install from source
# This is required for the pre-commit tests
shell: pwsh
run: python -m pip install -e '.[test-cov]'
run: python -m pip install -e '.[test-external,test-cov]'

- name: Create kernel
shell: pwsh
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/step_tests-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
markdown-it-py-version: ["~=2.0"]
kernel: [true]
include:
- python-version: "3.12-dev"
experimental: true
Expand All @@ -28,14 +27,13 @@ jobs:
markdown-it-py-version: ""
- python-version: "3.x"
markdown-it-py-version: "~=3.0"
- python-version: "3.11"
- python-version: "3.x"
markdown-it-py-version: "~=4.0"
experimental: true
- python-version: "3.x"
kernel: false
no_kernel: true
- python-version: "3.x"
quarto: true
kernel: true

steps:
- name: Checkout
Expand All @@ -46,11 +44,11 @@ jobs:
with:
python_version: ${{ matrix.python-version }}

- name: Install from source (required for the pre-commit tests)
run: python -m pip install -e '.[test-cov]' ${{ matrix.markdown-it-py-version && format('markdown-it-py{0}', matrix.markdown-it-py-version) }}
- name: Install from source
run: python -m pip install -e '.[test-cov,test-external]' ${{ matrix.markdown-it-py-version && format('markdown-it-py{0}', matrix.markdown-it-py-version) }}

- name: Install a Jupyter Kernel
if: ${{ matrix.kernel }}
if: ${{ !matrix.no_kernel }}
run: python -m ipykernel install --name python_kernel --user

- name: Install Quarto
Expand All @@ -66,6 +64,7 @@ jobs:
- name: Test lab extension
run: |
# Check extension
pip install jupyterlab
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "jupyterlab-jupytext.*OK"
python -m jupyterlab.browser_check
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/step_tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ jobs:
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install from source (required for the pre-commit tests)
run: python -m pip install -e '.[test-cov]'
- name: Install from source
run: python -m pip install -e .

- name: Install galata
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install
run: |
pip install jupyterlab
jlpm install

- name: Install browser
working-directory: jupyterlab/packages/jupyterlab-jupytext-extension/ui-tests
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/step_tests_categories-pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: test-categories
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These need to be added to .github/workflows/ci.yaml.
Also, remind me to make a PR to re-organize these CI files.

run-name: Run Unit/Functional/Integration and External tests using Pip

on:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-pip-test
cancel-in-progress: true

jobs:
test-pip:
continue-on-error: ${{ matrix.experimental || false }}
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: ${{ matrix.python-version }}

- name: Install from source
run: python -m pip install -e '.[test-cov]' markdown-it-py~=3.0

- name: Unit tests
run: pytest tests/unit --cov=src/jupytext --cov-report=xml

- name: Functional tests
run: pytest tests/functional --cov=src/jupytext --cov-report=xml

- name: Install the integration test dependencies
run: python -m pip install -e '.[test-integration]'

- name: Install a Jupyter Kernel
run: python -m ipykernel install --name python_kernel --user

- name: Integration tests
run: pytest tests/integration --cov=src/jupytext --cov-report=xml

- name: Install the external test dependencies
run: python -m pip install -e '.[test-external]'

- name: External tests
run: pytest tests/external --cov=src/jupytext --cov-report=xml

- name: Upload coverage
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
exclude: >
(?x)^(
demo/.*|
tests/notebooks/.*|
tests/data/notebooks/.*|
)$
repos:

Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ You want to submit an enhancement on Jupytext? Unless this is a small change, we
A pull request for which you do not need to contact us in advance is the addition of a new language to Jupytext. In principle that should be easy - you would only have to:
- document the language extension and comment by adding one line to `_SCRIPT_EXTENSIONS` in `jupytext/languages.py`.
- add the language to `docs/languages.md`
- contribute a sample notebook in `tests/notebooks/ipynb_[language]`.
- run the tests suite (create a [development environment](developing.md), then execute `pytest` locally). The tests will generate various text representations corresponding to your notebook under `tests/notebooks/mirror/`. Please verify that these files are valid scripts, and include them in your PR.
- contribute a sample notebook in `tests/data/notebooks/inputs/ipynb_[language]`.
- run the tests suite (create a [development environment](developing.md), then execute `pytest` locally). The tests will generate various text representations corresponding to your notebook under `tests/data/notebooks/outputs/`. Please verify that these files are valid scripts, and include them in your PR.
4 changes: 2 additions & 2 deletions docs/using-pre-commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ repos:
language_version: python3
```

Tested examples of how to use the pre-commit hook are available in our [tests](https://github.com/mwouts/jupytext/tree/main/tests) -
see for instance [test_pre_commit_1_sync_with_config.py](https://github.com/mwouts/jupytext/blob/main/tests/test_pre_commit_1_sync_with_config.py).
Tested examples of how to use the pre-commit hook are available in our [tests](https://github.com/mwouts/jupytext/tree/main/tests/functional/pre-commit) -
see for instance [test_pre_commit_1_sync_with_config.py](https://github.com/mwouts/jupytext/blob/main/tests/functional/pre-commit/test_pre_commit_1_sync_with_config.py).
19 changes: 1 addition & 18 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ dependencies:
- python>=3.8
- jupyterlab>=4.0.0
- nbformat>=5.1.2
- pyyaml
- toml
- markdown-it-py>=1.0.0,<3.0.0
- mdit-py-plugins
- nbconvert
- ipykernel
- pytest
- pytest-xdist
- pytest-randomly
- pytest-cov
- pre-commit
- gitpython
- pylint
- flake8
- black==23.11.0
- isort==5.12.0
- autopep8
- sphinx-gallery<0.8
- pandoc==2.16.2
- nodejs>=20
- pandoc==2.16.2
85 changes: 64 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,44 @@ Documentation = "https://jupytext.readthedocs.io"

[project.optional-dependencies]
# Test related dependencies
# TODO: Split them into unit, integration and functional tests groups
test = [
"autopep8",
"black",
"isort",
"ruff",
"flake8",
"pytest",
"pytest-randomly",
"gitpython",
"jupyterlab",
"notebook",
"nbconvert",
# jupyter-fs==0.4.0 is async, which is not supported by Jupytext ATM
"jupyter-fs<0.4.0",
"ipykernel",
"pre-commit",
"pytest",
"pytest-randomly"
]
test-functional = [
"jupytext[test]",
]
test-integration = [
"jupytext[test-functional]",
"jupyter-server",
# jupytext --execute
"nbconvert",
"ipykernel",
]
test-external = [
"jupytext[test-integration]",
# jupytext --pipe and --check
"autopep8",
"black",
"isort",
"flake8",
# Sphinx gallery
"sphinx-gallery<0.8",
# Pre-commit tests
"gitpython",
"pre-commit",
# Interaction with other contents managers
# jupyter-fs==0.4.0 is async, which is not supported by Jupytext ATM
"jupyter-fs<0.4.0"
]
# Coverage requirements
test-cov = [
"jupytext[test]",
"jupytext[test-integration]",
"pytest-cov>=2.6.1",
]
dev = [
"jupytext[test]",
"pre-commit"
]
# Documentation dependencies
docs = [
Expand Down Expand Up @@ -103,9 +116,7 @@ path = "src/jupytext/version.py"
# Following config is related to JupyterLab extension
[tool.hatch.build.targets.sdist]
artifacts = ["jupyterlab/jupyterlab_jupytext/labextension"]
# Exclude tests (contains Notebooks that have a total size of ~8MB) to reduce sdist
# tarball. (See #1142)
exclude = ["tests", "demo", "**/.yarn", "**/node_modules"]
exclude = ["demo", "**/.yarn", "**/node_modules"]

[tool.hatch.build.targets.wheel]
packages = ["src/jupytext", "src/jupytext_config", "jupyterlab/jupyterlab_jupytext"]
Expand Down Expand Up @@ -163,7 +174,7 @@ ignore = ["W002"]
[tool.ruff]
line-length = 127
exclude = [
"tests/notebooks/*",
"tests/data/notebooks/*",
]
# Seems like W503 is not implemented in ruff
# ref: https://github.com/astral-sh/ruff/issues/4125
Expand All @@ -172,9 +183,41 @@ ignore = [
]

[tool.pytest.ini_options]
markers = [
"requires_jupytext",
"requires_black",
"requires_isort",
"requires_flake8",
"requires_autopep8",
"requires_nbconvert",
"requires_myst",
"requires_no_myst",
"requires_quarto",
"requires_pandoc",
"requires_no_pandoc",
"requires_sphinx_gallery",
"requires_user_kernel_python3",
"requires_ir_kernel",
mwouts marked this conversation as resolved.
Show resolved Hide resolved
"skip_on_windows",
"pre_commit",
]
filterwarnings = [
# Uncomment this "error" to turn all unfiltered warnings into errors
# "error",
# Our cwd_tmpdir fixture
"ignore:pathlib.Path.__enter__\\(\\) is deprecated and scheduled for removal in Python 3.13:DeprecationWarning",
# Pre-commit
"ignore:read_text is deprecated. Use files\\(\\) instead:DeprecationWarning",
"ignore:open_text is deprecated. Use files\\(\\) instead:DeprecationWarning",
# Jupyter
"ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning",
# Jupyter notebook
"ignore:Support for bleach <5 will be removed in a future version of nbconvert:DeprecationWarning",
# jupyterfs
"ignore:run_pre_save_hook is deprecated, use run_pre_save_hooks instead:DeprecationWarning",
"ignore:run_post_save_hook is deprecated, use run_post_save_hooks instead:DeprecationWarning",
"ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning",
"ignore:pkg_resources is deprecated as an API:DeprecationWarning",
# use single quote to denote raw strings in toml
# (10 warnings)
'ignore:Passing unrecognized arguments to super\(KernelSpec\).__init__:DeprecationWarning',
Expand Down
7 changes: 3 additions & 4 deletions src/jupytext/parse_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
def parse_version(version, custom_error=ImportError):
try:
from pkg_resources import parse_version as parse
from packaging.version import parse
mwouts marked this conversation as resolved.
Show resolved Hide resolved
except ImportError:
try:
from packaging.version import parse
from pkg_resources import parse_version as parse
except ImportError:
raise custom_error("Please install either pkg_resources or packaging")
raise custom_error("Please install either packaging or pkg_resources")

print(version)
return parse(version)
Loading
Loading