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

small test changes #541

Merged
merged 5 commits into from
Jul 8, 2021
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
6 changes: 5 additions & 1 deletion .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
Expand All @@ -22,11 +23,14 @@ jobs:
- name: Install dependencies
run: |
pip install --upgrade pip
pip install ".[test]"
pip install "."
pip install --pre --upgrade jupyterlab_server[test] jupyterlab[test] nbclassic[test]
pip freeze
- name: Run tests
working-directory: ../
run: |
# NOTE: tests won't pass from inside the working copy because of
# conftest.py:pytest_plugins (must be at the top level)
pytest --pyargs jupyterlab_server
python -m jupyterlab.browser_check --no-browser-test

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu]
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
Expand All @@ -28,10 +28,10 @@ jobs:
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
Expand All @@ -44,4 +44,4 @@ jobs:
pip check
- name: Run the tests
run: |
pytest -vv --integration_tests jupyter_server
pytest -vv --integration_tests=true
16 changes: 8 additions & 8 deletions .github/workflows/python-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu]
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
Expand All @@ -28,10 +28,10 @@ jobs:
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
Expand All @@ -45,17 +45,17 @@ jobs:
- name: Run the tests
if: ${{ matrix.python-version != 'pypy3' }}
run: |
pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
- name: Run the tests on pypy
if: ${{ matrix.python-version == 'pypy3' }}
run: |
pytest -vv jupyter_server
pytest -vv
- name: Install the Python dependencies for the examples
run: |
cd examples/simple && pip install -e .
- name: Run the tests for the examples
run: |
pytest examples/simple/tests/test_handlers.py
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD
- name: Coverage
if: ${{ matrix.python-version != 'pypy3' }}
run: |
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/python-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
fail-fast: false
matrix:
os: [macos]
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
Expand All @@ -28,10 +28,10 @@ jobs:
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
Expand All @@ -45,17 +45,17 @@ jobs:
- name: Run the tests
if: ${{ matrix.python-version != 'pypy3' }}
run: |
pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
- name: Run the tests on pypy
if: ${{ matrix.python-version == 'pypy3' }}
run: |
pytest -vv jupyter_server
pytest -vv
- name: Install the Python dependencies for the examples
run: |
cd examples/simple && pip install -e .
- name: Run the tests for the examples
run: |
pytest examples/simple/tests/test_handlers.py
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD
- name: Coverage
if: ${{ matrix.python-version != 'pypy3' }}
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/python-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
Expand All @@ -28,10 +28,10 @@ jobs:
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
Expand All @@ -49,10 +49,10 @@ jobs:
# the file descriptions opened by the asyncio IOLoop.
# This leads to a nasty, flaky race condition that we haven't
# been able to solve.
pytest -vv jupyter_server -s
pytest -vv -s
- name: Install the Python dependencies for the examples
run: |
cd examples/simple && pip install -e .
- name: Run the tests for the examples
run: |
pytest examples/simple/tests/test_handlers.py
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD
2 changes: 2 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ Running Tests
Install dependencies::

pip install -e .[test]
pip install -e examples/simple

To run the Python tests, use::

pytest
pytest examples/simple

Building the Docs
=================
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ Launch with:

### Testing

To test an installed `jupyter_server`, run the following:

pip install jupyter_server[test]
pytest jupyter_server
See [CONTRIBUTING](https://github.com/jupyter-server/jupyter_server/blob/master/CONTRIBUTING.rst#running-tests).

## Contributing

Expand Down
5 changes: 1 addition & 4 deletions jupyter_server/tests/conftest.py → conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
]


import pytest


def pytest_addoption(parser):
parser.addoption(
"--integration_tests",
Expand All @@ -26,7 +23,7 @@ def pytest_configure(config):


def pytest_runtest_setup(item):
is_integration_test = any([mark for mark in item.iter_markers(name="integration_test")])
is_integration_test = any(mark for mark in item.iter_markers(name="integration_test"))

if item.config.getoption("--integration_tests") is True:
if not is_integration_test:
Expand Down
3 changes: 0 additions & 3 deletions examples/simple/tests/conftest.py

This file was deleted.

10 changes: 5 additions & 5 deletions jupyter_server/auth/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def passwd(passphrase=None, algorithm='argon2'):

Examples
--------
>>> passwd('mypassword')
'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12'
>>> passwd('mypassword') # doctest: +ELLIPSIS
'argon2:...'

"""
if passphrase is None:
Expand Down Expand Up @@ -94,11 +94,11 @@ def passwd_check(hashed_passphrase, passphrase):

Examples
--------
>>> from jupyter_server.auth.security import passwd_check
>>> passwd_check('argon2:...', 'mypassword')
>>> myhash = passwd('mypassword')
>>> passwd_check(myhash, 'mypassword')
True

>>> passwd_check('argon2:...', 'otherpassword')
>>> passwd_check(myhash, 'otherpassword')
False

>>> passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a',
Expand Down
10 changes: 6 additions & 4 deletions jupyter_server/traittypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ class name where an object was defined.
'an object'
>>> describe("a", type(object))
'a type'

Definite description:
>>> describe("the", object())
"the object at '0x10741f1b0'"
>>> describe("the", object()) # doctest: +ELLIPSIS
"the object at '0x...'"
>>> describe("the", object)
"the type 'object'"
'the object object'
>>> describe("the", type(object))
"the type 'type'"
'the type type'

Definitely named description:
>>> describe("the", object(), "I made")
'the object I made'
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ build-backend = "jupyter_packaging.build_api"
factory = "jupyter_packaging.npm_builder"

[tool.check-manifest]
ignore = ["tbump.toml", ".*", "*.yml", "package-lock.json", "bootstrap*"]
ignore = ["tbump.toml", ".*", "*.yml", "package-lock.json", "bootstrap*", "conftest.py"]

[tool.pytest.ini_options]
# Exclude the example tests.
norecursedirs = "examples/*"
addopts = "--doctest-modules"
testpaths = [
"jupyter_server"
]

[tool.tbump.version]
current = "1.10.0.dev0"
Expand Down
12 changes: 11 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@ install_requires =
requests-unixsocket

[options.extras_require]
test = coverage; pytest; pytest-cov; pytest-mock; requests; pytest-tornasync; pytest-console-scripts; ipykernel
test =
coverage
pytest>=6.0
pytest-cov
pytest-mock
requests
pytest-tornasync
pytest-console-scripts
ipykernel
# NOTE: we cannot auto install examples/simple here because of:
# https://github.com/pypa/pip/issues/6658

[options.entry_points]
console_scripts =
Expand Down