Skip to content

Commit e3b2dad

Browse files
small test changes (#541)
* actions: use setup.cfg as the cache key * the dependencies are specified in setup.cfg rather than .py * tests: compatibility with pytest>=4 * fix defining pytest_plugins in non-top-level conftest file (pytest 3+) https://docs.pytest.org/en/6.2.x/deprecations.html#pytest-plugins-in-non-top-level-conftest-files * update to pytest 6 as this was the first version to support pyproject.toml https://docs.pytest.org/en/stable/changelog.html#id123 * tests: run doctests * actions: run tests against development versions of python * actions: bump action versions
1 parent 195ed51 commit e3b2dad

File tree

13 files changed

+64
-53
lines changed

13 files changed

+64
-53
lines changed

.github/workflows/downstream.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
jobs:
1010
tests:
1111
runs-on: ubuntu-latest
12+
timeout-minutes: 15
1213

1314
steps:
1415
- name: Checkout
@@ -22,11 +23,14 @@ jobs:
2223
- name: Install dependencies
2324
run: |
2425
pip install --upgrade pip
25-
pip install ".[test]"
26+
pip install "."
2627
pip install --pre --upgrade jupyterlab_server[test] jupyterlab[test] nbclassic[test]
2728
pip freeze
2829
- name: Run tests
30+
working-directory: ../
2931
run: |
32+
# NOTE: tests won't pass from inside the working copy because of
33+
# conftest.py:pytest_plugins (must be at the top level)
3034
pytest --pyargs jupyterlab_server
3135
python -m jupyterlab.browser_check --no-browser-test
3236

.github/workflows/integration-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [ubuntu]
14-
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
14+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v1
17+
uses: actions/checkout@v2
1818
- name: Install Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v2
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
architecture: 'x64'
@@ -28,10 +28,10 @@ jobs:
2828
run: |
2929
echo "::set-output name=dir::$(pip cache dir)"
3030
- name: Cache pip
31-
uses: actions/cache@v1
31+
uses: actions/cache@v2
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
34-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
34+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
3535
restore-keys: |
3636
${{ runner.os }}-pip-${{ matrix.python-version }}-
3737
${{ runner.os }}-pip-
@@ -44,4 +44,4 @@ jobs:
4444
pip check
4545
- name: Run the tests
4646
run: |
47-
pytest -vv --integration_tests jupyter_server
47+
pytest -vv --integration_tests=true

.github/workflows/python-linux.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [ubuntu]
14-
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
14+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v1
17+
uses: actions/checkout@v2
1818
- name: Install Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v2
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
architecture: 'x64'
@@ -28,10 +28,10 @@ jobs:
2828
run: |
2929
echo "::set-output name=dir::$(pip cache dir)"
3030
- name: Cache pip
31-
uses: actions/cache@v1
31+
uses: actions/cache@v2
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
34-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
34+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
3535
restore-keys: |
3636
${{ runner.os }}-pip-${{ matrix.python-version }}-
3737
${{ runner.os }}-pip-
@@ -45,17 +45,17 @@ jobs:
4545
- name: Run the tests
4646
if: ${{ matrix.python-version != 'pypy3' }}
4747
run: |
48-
pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
48+
pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
4949
- name: Run the tests on pypy
5050
if: ${{ matrix.python-version == 'pypy3' }}
5151
run: |
52-
pytest -vv jupyter_server
52+
pytest -vv
5353
- name: Install the Python dependencies for the examples
5454
run: |
5555
cd examples/simple && pip install -e .
5656
- name: Run the tests for the examples
5757
run: |
58-
pytest examples/simple/tests/test_handlers.py
58+
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD
5959
- name: Coverage
6060
if: ${{ matrix.python-version != 'pypy3' }}
6161
run: |

.github/workflows/python-macos.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
os: [macos]
14-
python-version: [ '3.6', '3.7', '3.8', '3.9', 'pypy3' ]
14+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10-dev', 'pypy3' ]
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v1
17+
uses: actions/checkout@v2
1818
- name: Install Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v2
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
architecture: 'x64'
@@ -28,10 +28,10 @@ jobs:
2828
run: |
2929
echo "::set-output name=dir::$(pip cache dir)"
3030
- name: Cache pip
31-
uses: actions/cache@v1
31+
uses: actions/cache@v2
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
34-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
34+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
3535
restore-keys: |
3636
${{ runner.os }}-pip-${{ matrix.python-version }}-
3737
${{ runner.os }}-pip-
@@ -45,17 +45,17 @@ jobs:
4545
- name: Run the tests
4646
if: ${{ matrix.python-version != 'pypy3' }}
4747
run: |
48-
pytest -vv jupyter_server --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
48+
pytest -vv --cov jupyter_server --cov-branch --cov-report term-missing:skip-covered
4949
- name: Run the tests on pypy
5050
if: ${{ matrix.python-version == 'pypy3' }}
5151
run: |
52-
pytest -vv jupyter_server
52+
pytest -vv
5353
- name: Install the Python dependencies for the examples
5454
run: |
5555
cd examples/simple && pip install -e .
5656
- name: Run the tests for the examples
5757
run: |
58-
pytest examples/simple/tests/test_handlers.py
58+
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD
5959
- name: Coverage
6060
if: ${{ matrix.python-version != 'pypy3' }}
6161
run: |

.github/workflows/python-windows.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
1515
steps:
1616
- name: Checkout
17-
uses: actions/checkout@v1
17+
uses: actions/checkout@v2
1818
- name: Install Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v1
19+
uses: actions/setup-python@v2
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
architecture: 'x64'
@@ -28,10 +28,10 @@ jobs:
2828
run: |
2929
echo "::set-output name=dir::$(pip cache dir)"
3030
- name: Cache pip
31-
uses: actions/cache@v1
31+
uses: actions/cache@v2
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
34-
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
34+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.cfg') }}
3535
restore-keys: |
3636
${{ runner.os }}-pip-${{ matrix.python-version }}-
3737
${{ runner.os }}-pip-
@@ -49,10 +49,10 @@ jobs:
4949
# the file descriptions opened by the asyncio IOLoop.
5050
# This leads to a nasty, flaky race condition that we haven't
5151
# been able to solve.
52-
pytest -vv jupyter_server -s
52+
pytest -vv -s
5353
- name: Install the Python dependencies for the examples
5454
run: |
5555
cd examples/simple && pip install -e .
5656
- name: Run the tests for the examples
5757
run: |
58-
pytest examples/simple/tests/test_handlers.py
58+
pytest examples/simple/tests/test_handlers.py --confcutdir=$PWD

CONTRIBUTING.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ Running Tests
5858
Install dependencies::
5959

6060
pip install -e .[test]
61+
pip install -e examples/simple
6162

6263
To run the Python tests, use::
6364

6465
pytest
66+
pytest examples/simple
6567

6668
Building the Docs
6769
=================

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ Launch with:
3535

3636
### Testing
3737

38-
To test an installed `jupyter_server`, run the following:
39-
40-
pip install jupyter_server[test]
41-
pytest jupyter_server
38+
See [CONTRIBUTING](https://github.com/jupyter-server/jupyter_server/blob/master/CONTRIBUTING.rst#running-tests).
4239

4340
## Contributing
4441

jupyter_server/tests/conftest.py renamed to conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
]
77

88

9-
import pytest
10-
11-
129
def pytest_addoption(parser):
1310
parser.addoption(
1411
"--integration_tests",
@@ -26,7 +23,7 @@ def pytest_configure(config):
2623

2724

2825
def pytest_runtest_setup(item):
29-
is_integration_test = any([mark for mark in item.iter_markers(name="integration_test")])
26+
is_integration_test = any(mark for mark in item.iter_markers(name="integration_test"))
3027

3128
if item.config.getoption("--integration_tests") is True:
3229
if not is_integration_test:

examples/simple/tests/conftest.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

jupyter_server/auth/security.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def passwd(passphrase=None, algorithm='argon2'):
4343
4444
Examples
4545
--------
46-
>>> passwd('mypassword')
47-
'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12'
46+
>>> passwd('mypassword') # doctest: +ELLIPSIS
47+
'argon2:...'
4848
4949
"""
5050
if passphrase is None:
@@ -94,11 +94,11 @@ def passwd_check(hashed_passphrase, passphrase):
9494
9595
Examples
9696
--------
97-
>>> from jupyter_server.auth.security import passwd_check
98-
>>> passwd_check('argon2:...', 'mypassword')
97+
>>> myhash = passwd('mypassword')
98+
>>> passwd_check(myhash, 'mypassword')
9999
True
100100
101-
>>> passwd_check('argon2:...', 'otherpassword')
101+
>>> passwd_check(myhash, 'otherpassword')
102102
False
103103
104104
>>> passwd_check('sha1:0e112c3ddfce:a68df677475c2b47b6e86d0467eec97ac5f4b85a',

0 commit comments

Comments
 (0)