Skip to content

Commit

Permalink
Merge pull request jupyter-server#416 from afshin/tests-distribution
Browse files Browse the repository at this point in the history
Add Tests to Distribution
  • Loading branch information
Zsailer authored Feb 18, 2021
2 parents 4bf307d + cbe23fb commit 4933c90
Show file tree
Hide file tree
Showing 66 changed files with 64 additions and 37 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/python-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,26 @@ jobs:
pip freeze
pip check
- name: Run the tests
if: ${{ matrix.python-version != 'pypy3' }}
run: |
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
- 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
- name: Coverage
if: ${{ matrix.python-version != 'pypy3' }}
run: |
codecov
- name: Test full install
run: |
pip uninstall -y jupyter_server
pip install .
cd /tmp
pytest --pyargs jupyter_server
6 changes: 6 additions & 0 deletions .github/workflows/python-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@ jobs:
pip freeze
pip check
- name: Run the tests
if: ${{ matrix.python-version != 'pypy3' }}
run: |
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
- 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
- name: Coverage
if: ${{ matrix.python-version != 'pypy3' }}
run: |
codecov
2 changes: 1 addition & 1 deletion .github/workflows/python-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
${{ runner.os }}-pip-
- name: Install the Python dependencies
run: |
pip install -e .[test] codecov
pip install -e .[test]
- name: List installed packages
run: |
pip freeze
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To install the latest release locally, make sure you have

$ pip install jupyter_server

Jupyter Server currently supports Python>=3.5 on Linux, OSX and Windows.
Jupyter Server currently supports Python>=3.6 on Linux, OSX and Windows.

### Versioning and Branches

Expand All @@ -33,6 +33,13 @@ Launch with:

$ jupyter server

### Testing

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

$ pip install jupyter_server[test]
$ pytest --pyargs jupyter_server

## Contributing

If you are interested in contributing to the project, see [`CONTRIBUTING.rst`](CONTRIBUTING.rst).
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
def _jupyter_server_extension_points():
return [
{
'module': 'tests.extension.mockextensions.app',
'module': 'jupyter_server.tests.extension.mockextensions.app',
'app': MockExtensionApp
},
{
'module': 'tests.extension.mockextensions.mock1'
'module': 'jupyter_server.tests.extension.mockextensions.mock1'
},
{
'module': 'tests.extension.mockextensions.mock2'
'module': 'jupyter_server.tests.extension.mockextensions.mock2'
},
{
'module': 'tests.extension.mockextensions.mock3'
'module': 'jupyter_server.tests.extension.mockextensions.mock3'
}
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mock1'
'module': 'jupyter_server.tests.extension.mockextensions.mock1'
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mock2'
'module': 'jupyter_server.tests.extension.mockextensions.mock2'
}
]

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mockext_both'
'module': 'jupyter_server.tests.extension.mockextensions.mockext_both'
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mockext_py'
'module': 'jupyter_server.tests.extension.mockextensions.mockext_py'
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mockext_sys'
'module': 'jupyter_server.tests.extension.mockextensions.mockext_sys'
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def _jupyter_server_extension_paths():
return [
{
'module': 'tests.extension.mockextensions.mockext_user'
'module': 'jupyter_server.tests.extension.mockextensions.mockext_user'
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def jp_server_config(jp_template_dir):
config = {
"ServerApp": {
"jpserver_extensions": {
"tests.extension.mockextensions": True
"jupyter_server.tests.extension.mockextensions": True
},
},
"MockExtensionApp": {
Expand All @@ -22,7 +22,7 @@ def jp_server_config(jp_template_dir):

@pytest.fixture
def mock_extension(extension_manager):
name = "tests.extension.mockextensions"
name = "jupyter_server.tests.extension.mockextensions"
pkg = extension_manager.extensions[name]
point = pkg.extension_points["mockextension"]
app = point.app
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def jp_server_config(jp_template_dir):
return {
"ServerApp": {
"jpserver_extensions": {
"tests.extension.mockextensions": True
"jupyter_server.tests.extension.mockextensions": True
}
},
"MockExtensionApp": {
Expand Down Expand Up @@ -40,7 +40,7 @@ async def test_handler_template(jp_fetch, mock_template):
{
"ServerApp": {
"jpserver_extensions": {
"tests.extension.mockextensions": True
"jupyter_server.tests.extension.mockextensions": True
}
},
"MockExtensionApp": {
Expand Down Expand Up @@ -81,7 +81,7 @@ async def test_handler_argv(jp_fetch, jp_argv):
{
"ServerApp": {
"jpserver_extensions": {
"tests.extension.mockextensions": True
"jupyter_server.tests.extension.mockextensions": True
},
# Move extension handlers behind a url prefix
"base_url": "test_prefix"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _kill_extension_app():
f'--port={port}',
'--ip=127.0.0.1',
'--no-browser',
f'--ServerApp.token={token}',
f'--ServerApp.token="{token}"',
*argv,
], cwd=HERE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_extension_package_api():
path1 = metadata_list[0]
app = path1["app"]

e = ExtensionPackage(name='tests.extension.mockextensions')
e = ExtensionPackage(name='jupyter_server.tests.extension.mockextensions')
e.extension_points
assert hasattr(e, "extension_points")
assert len(e.extension_points) == len(metadata_list)
Expand All @@ -68,16 +68,16 @@ def test_extension_package_notfound_error():

def test_extension_manager_api():
jpserver_extensions = {
"tests.extension.mockextensions": True
"jupyter_server.tests.extension.mockextensions": True
}
manager = ExtensionManager()
manager.from_jpserver_extensions(jpserver_extensions)
assert len(manager.extensions) == 1
assert "tests.extension.mockextensions" in manager.extensions
assert "jupyter_server.tests.extension.mockextensions" in manager.extensions


def test_extension_manager_linked_extensions(jp_serverapp):
name = "tests.extension.mockextensions"
name = "jupyter_server.tests.extension.mockextensions"
manager = ExtensionManager()
manager.add_extension(name, enabled=True)
manager.link_extension(name, jp_serverapp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def test_merge_config(
# Toggle each extension module with a JSON config file
# at the sys-prefix config dir.
toggle_server_extension_python(
'tests.extension.mockextensions.mockext_sys',
'jupyter_server.tests.extension.mockextensions.mockext_sys',
enabled=True,
sys_prefix=True
)
toggle_server_extension_python(
'tests.extension.mockextensions.mockext_user',
'jupyter_server.tests.extension.mockextensions.mockext_user',
enabled=True,
user=True
)
Expand All @@ -65,18 +65,18 @@ def test_merge_config(
# sys-prefix supercedes users, so the extension should be disabled
# when these two configs merge.
toggle_server_extension_python(
'tests.extension.mockextensions.mockext_both',
'jupyter_server.tests.extension.mockextensions.mockext_both',
enabled=True,
sys_prefix=True
)
toggle_server_extension_python(
'tests.extension.mockextensions.mockext_both',
'jupyter_server.tests.extension.mockextensions.mockext_both',
enabled=False,
user=True
)

arg = "--ServerApp.jpserver_extensions={{'{mockext_py}': True}}".format(
mockext_py='tests.extension.mockextensions.mockext_py'
mockext_py='jupyter_server.tests.extension.mockextensions.mockext_py'
)

# Enable the last extension, mockext_py, using the CLI interface.
Expand All @@ -86,11 +86,11 @@ def test_merge_config(
)
# Verify that extensions are enabled and merged in proper order.
extensions = app.jpserver_extensions
assert extensions['tests.extension.mockextensions.mockext_user']
assert extensions['tests.extension.mockextensions.mockext_sys']
assert extensions['tests.extension.mockextensions.mockext_py']
assert extensions['jupyter_server.tests.extension.mockextensions.mockext_user']
assert extensions['jupyter_server.tests.extension.mockextensions.mockext_sys']
assert extensions['jupyter_server.tests.extension.mockextensions.mockext_py']
# Merging should causes this extension to be disabled.
assert not extensions['tests.extension.mockextensions.mockext_both']
assert not extensions['jupyter_server.tests.extension.mockextensions.mockext_both']


@pytest.mark.parametrize(
Expand All @@ -99,8 +99,8 @@ def test_merge_config(
{
"ServerApp": {
"jpserver_extensions": OrderedDict([
('tests.extension.mockextensions.mock2', True),
('tests.extension.mockextensions.mock1', True)
('jupyter_server.tests.extension.mockextensions.mock2', True),
('jupyter_server.tests.extension.mockextensions.mock1', True)
])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

def test_validate_extension():
# enabled at sys level
assert validate_extension('tests.extension.mockextensions.mockext_sys')
assert validate_extension('jupyter_server.tests.extension.mockextensions.mockext_sys')
# enabled at sys, disabled at user
assert validate_extension('tests.extension.mockextensions.mockext_both')
assert validate_extension('jupyter_server.tests.extension.mockextensions.mockext_both')
# enabled at user
assert validate_extension('tests.extension.mockextensions.mockext_user')
assert validate_extension('jupyter_server.tests.extension.mockextensions.mockext_user')
# enabled at Python
assert validate_extension('tests.extension.mockextensions.mockext_py')
assert validate_extension('jupyter_server.tests.extension.mockextensions.mockext_py')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[pytest]
# Exclude the example tests.
norecursedirs = examples/*
# Work around for https://github.com/pytest-dev/pytest/issues/4039
addopts = --pyargs jupyter_server

0 comments on commit 4933c90

Please sign in to comment.