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

basic approach for separate pytest plugin package #338

Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
architecture: 'x64'
- name: Install the Python dependencies
run: |
pip install -e .[test]
pip install -r requirements.txt
- name: Run the tests
run: |
pytest
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Running Tests

Install dependencies::

pip install -e .[test]
pip install -e .[test] ./pytest_plugin

To run the Python tests, use::

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include CHANGELOG.md
include setupbase.py

# include everything in package_data
include jupyter_server/**/*
recursive-include jupyter_server *

# Documentation
graft docs
Expand Down
60 changes: 60 additions & 0 deletions pytest_plugin/COPYING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Licensing terms

This project is licensed under the terms of the Modified BSD License
(also known as New or Revised or 3-Clause BSD), as follows:

- Copyright (c) 2001-2015, IPython Development Team
- Copyright (c) 2015-, Jupyter Development Team

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

Neither the name of the Jupyter Development Team nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

## About the Jupyter Development Team

The Jupyter Development Team is the set of all contributors to the Jupyter project.
This includes all of the Jupyter subprojects.

The core team that coordinates development on GitHub can be found here:
https://github.com/jupyter/.

## Our Copyright Policy

Jupyter uses a shared copyright model. Each contributor maintains copyright
over their contributions to Jupyter. But, it is important to note that these
contributions are typically only changes to the repositories. Thus, the Jupyter
source code, in its entirety is not the copyright of any single person or
institution. Instead, it is the collective copyright of the entire Jupyter
Development Team. If individual contributors want to maintain a record of what
changes/contributions they have specific copyright on, they should indicate
their copyright in the commit message of the change, when they commit the
change to one of the Jupyter repositories.

With this in mind, the following banner should be used in any source code file
to indicate the copyright and license terms:

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
1 change: 1 addition & 0 deletions pytest_plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# pytest_jupyter_server
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""pytest fixtures for testing jupyter_server and extensions"""

import os
import sys
import json
Expand All @@ -20,8 +22,7 @@

import nbformat

# This shouldn't be needed anymore, since pytest_tornasync is found in entrypoints
pytest_plugins = "pytest_tornasync"
__version__ = "0.1.0"

# NOTE: This is a temporary fix for Windows 3.8
# We have to override the io_loop fixture with an
Expand Down
39 changes: 39 additions & 0 deletions pytest_plugin/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[metadata]
author = Jupyter Development Team
author-email = [email protected]
summary = Pytest fixtures for Jupyter Server
description-file = README.md
long-description-content-type = text/markdown
home-page = https://github.com/jupyter/jupyter_server
license = BSD-3-Clause
license-file = COPYING.md
python-requires = >=3.6
classifier =
Framework :: Jupyter
Framework :: Pytest
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Quality Assurance
Topic :: Software Development :: Testing
keywords =
testing

[options]
py_modules =
pytest_jupyter_server

install_requires =
pytest
pytest_tornasync


[options.entry_points]
pytest11 =
pytest_jupyter_server = pytest_jupyter_server
12 changes: 12 additions & 0 deletions pytest_plugin/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pathlib import Path

import setuptools
from re import findall


here = Path(__file__).parent
name = "pytest_jupyter_server"
version = findall(r'__version__ = "(.+)"', (here / f"{name}.py").read_text())[0]

if __name__ == "__main__":
setuptools.setup(name=name, version=version)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e ./pytest_plugin
-e .[test]
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,14 @@
],
extras_require = {
'test': ['nose', 'coverage', 'requests', 'nose_warnings_filters',
'pytest', 'pytest-cov', 'pytest-tornasync',
'pytest', 'pytest-cov', 'pytest_jupyter_server',
'pytest-console-scripts', 'ipykernel'],
'test:sys_platform == "win32"': ['nose-exclude'],
},
python_requires = '>=3.6',
entry_points = {
'console_scripts': [
'jupyter-server = jupyter_server.serverapp:main',
],
'pytest11': [
'pytest_jupyter_server = jupyter_server.pytest_plugin'
]
},
)
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
pytest_plugins = ['pytest_jupyter_server']
4 changes: 2 additions & 2 deletions tests/services/kernelspecs/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import tornado

from jupyter_server.pytest_plugin import some_resource
from pytest_jupyter_server import some_resource

from jupyter_client.kernelspec import NATIVE_KERNEL_NAME

Expand Down Expand Up @@ -102,4 +102,4 @@ async def test_get_nonexistant_resource(fetch, kernelspecs):
'kernelspecs', 'sample', 'nonexistant.txt',
method='GET'
)
assert expected_http_error(e, 404)
assert expected_http_error(e, 404)
5 changes: 1 addition & 4 deletions tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from jupyter_server import __version__


pep440re = re.compile('^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$')
pep440re = re.compile(r'^(\d+)\.(\d+)\.(\d+((a|b|rc)\d+)?)(\.post\d+)?(\.dev\d*)?$')

def raise_on_bad_version(version):
if not pep440re.match(version):
Expand Down Expand Up @@ -43,6 +43,3 @@ def test_valid_pep440_versions(version):
# --------- Test current version --------------
def test_current_version():
raise_on_bad_version(__version__)