Skip to content

Use pytest-xdist #1032

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

Closed
wants to merge 4 commits into from
Closed
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: 4 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches: ["main"]
pull_request:
branches: ["*"]

env:
PYTHONDONTWRITEBYTECODE: 1

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ defaults:
run:
shell: bash -eux {0}

env:
PYTHONDONTWRITEBYTECODE: 1

jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -33,10 +36,10 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Run the tests
if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.os, 'windows') }}
run: hatch run cov:test -W default || hatch run cov:test -W default --lf
run: hatch run cov:test -W default -n auto || hatch run -W default test:test --lf
- name: Run the tests on pypy and windows
if: ${{ startsWith(matrix.python-version, 'pypy') || startsWith(matrix.os, 'windows') }}
run: hatch run test:test -W default || hatch run test:test -W default --lf
run: hatch run test:test -W default -n auto || hatch run test:test -W default --lf
- name: Coverage
run: |
pip install codecov
Expand All @@ -57,7 +60,7 @@ jobs:
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- run: |
pip install -U pre jupyter_client
hatch run test:test || hatch run test:test --lf
hatch run test:test -n auto || hatch run test:test --lf

pre-commit:
name: pre-commit
Expand Down Expand Up @@ -115,7 +118,7 @@ jobs:
- name: Install miniumum versions
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
- name: Run the unit tests
run: hatch run test:nowarn || hatch run test:nowarn --lf
run: pytest -vv -W -n auto default || pytest -vv -W default --lf

test_prereleases:
name: Test Prereleases
Expand All @@ -138,7 +141,7 @@ jobs:
pip check
- name: Run the tests
run: |
pytest -vv -W default || pytest -vv -W default --lf
pytest -vv -W default -n auto || pytest -vv -W default --lf

make_sdist:
name: Make SDist
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ test = [
"pytest-console-scripts",
"pytest-timeout",
"pytest-tornasync",
"pytest-xdist[psutil]",
"pytest>=7.0",
"requests",
"pre-commit"
Expand Down
63 changes: 34 additions & 29 deletions tests/services/kernels/test_cull.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
import platform
import sys

import jupyter_client
import pytest
Expand All @@ -12,37 +13,41 @@
CULL_INTERVAL = 1


@pytest.mark.parametrize(
"jp_server_config",
[
# Test the synchronous case
Config(
{
"ServerApp": {
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.MappingKernelManager",
"MappingKernelManager": {
"cull_idle_timeout": CULL_TIMEOUT,
"cull_interval": CULL_INTERVAL,
"cull_connected": False,
},
}
server_config = [
# Test the synchronous case
Config(
{
"ServerApp": {
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.MappingKernelManager",
"MappingKernelManager": {
"cull_idle_timeout": CULL_TIMEOUT,
"cull_interval": CULL_INTERVAL,
"cull_connected": False,
},
}
),
# Test the async case
Config(
{
"ServerApp": {
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager",
"AsyncMappingKernelManager": {
"cull_idle_timeout": CULL_TIMEOUT,
"cull_interval": CULL_INTERVAL,
"cull_connected": False,
},
}
}
),
# Test the async case
Config(
{
"ServerApp": {
"kernel_manager_class": "jupyter_server.services.kernels.kernelmanager.AsyncMappingKernelManager",
"AsyncMappingKernelManager": {
"cull_idle_timeout": CULL_TIMEOUT,
"cull_interval": CULL_INTERVAL,
"cull_connected": False,
},
}
),
],
)
}
),
]

# Only test synchronous manager on Linux
if sys.platform == "linux":
config = server_config[1:]


@pytest.mark.parametrize("jp_server_config", server_config)
async def test_cull_idle(jp_fetch, jp_ws_fetch):
r = await jp_fetch("api", "kernels", method="POST", allow_nonstandard_methods=True)
kernel = json.loads(r.body.decode())
Expand Down