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

chore: Modernize setuptools packaging with pyproject.toml #158

Merged
merged 17 commits into from
Aug 25, 2024
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ commit = True
tag = True
tag_name = {new_version}

[bumpversion:file:testbook/_version.py]
[bumpversion:file:pyproject.toml]
16 changes: 6 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,27 @@ on:
jobs:
build-n-test-n-coverage:
name: Build, test and code coverage
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-rc.2"]
env:
OS: ubuntu-latest
PYTHON: "3.8"

python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
pip install .[dev]
pip install tox-gh-actions
- name: Run the tests
run: tox
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ build:
image: latest

python:
version: 3.7
version: 3.11
install:
- method: pip
path: .
extra_requirements:
- sphinx
- docs
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ If you are contributing with documentation please jump to [building documentatio

We need to install the development package before we can run the tests. If anything is confusing below, always resort to the relevant documentation.

For the most basic test runs against python 3.6 use this tox subset (callable after `pip install tox`):
For the most basic test runs against python 3.11 use this tox subset (callable after `pip install tox`):

```bash
tox -e py36
tox -e py311
```

This will just execute the unittests against python 3.6 in a new virtual env. The first run will take longer to setup the virtualenv, but will be fast after that point.
This will just execute the unittests against python 3.11 in a new virtual env. The first run will take longer to setup the virtualenv, but will be fast after that point.

For a full test suite of all envs and linting checks simply run tox without any arguments

```bash
tox
```

This will require python3.5, python3.6, python3.7, and python 3.8 to be installed.
This will require python3.7, and python 3.8 to be installed.

Alternavitely pytest can be used if you have an environment already setup which works or has custom packages not present in the tox build.

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2020, nteract
Copyright (c) 2024, nteract
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ recursive-include testbook *.yaml
recursive-include testbook *.keep
recursive-include testbook *.txt

include setup.py
include requirements*.txt
include tox.ini
include pytest.ini
include README.md
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[![Build Status](https://github.com/nteract/testbook/workflows/CI/badge.svg)](https://github.com/nteract/testbook/actions)
[![image](https://codecov.io/github/nteract/testbook/coverage.svg?branch=master)](https://codecov.io/github/nteract/testbook?branch=master)
[![Documentation Status](https://readthedocs.org/projects/testbook/badge/?version=latest)](https://testbook.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.org/project/testbook/)
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)
[![image](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![image](https://img.shields.io/pypi/l/testbook.svg)](https://github.com/astral-sh/testbook/blob/main/LICENSE)
[![image](https://img.shields.io/pypi/pyversions/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

# testbook
Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Prerequisites

- First check that the CHANGELOG is up to date for the next release version
- Ensure dev requirements are installed `pip install -r requirements-dev.txt`
- Ensure dev requirements are installed `pip install ".[dev]"`

## Push to GitHub

Expand All @@ -19,6 +19,6 @@ git push upstream && git push upstream --tags
```bash
rm -rf dist/*
rm -rf build/*
python setup.py bdist_wheel
python -m build
twine upload dist/*
```
40 changes: 20 additions & 20 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
#
import os
import sys
from importlib.metadata import version as read_version


sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------

project = 'testbook'
copyright = '2020, nteract team'
copyright = '2024, nteract team'
author = 'nteract team'


Expand Down Expand Up @@ -49,27 +51,27 @@

# General information about the project.
project = 'testbook'
copyright = '2020, nteract team'
copyright = '2024, nteract team'
author = 'nteract team'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import testbook


# The short X.Y version.
version = '.'.join(testbook.__version__.split('.')[0:2])
version = '.'.join(read_version(project).split('.')[0:2])

# The full version, including alpha/beta/rc tags.
release = testbook.__version__
release = read_version(project)

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line foexitr these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -96,25 +98,18 @@
#

html_theme_options = {
"path_to_docs": "docs",
"repository_url": "https://github.com/nteract/testbook",
"repository_branch": "main",
"use_edit_page_button": True,
'path_to_docs': 'docs',
'repository_url': 'https://github.com/nteract/testbook',
'repository_branch': 'main',
'use_edit_page_button': True,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {'**': ['about.html', 'navigation.html', 'relations.html', 'searchbox.html']}

html_title = "testbook"
html_title = 'testbook'

# -- Options for HTMLHelp output ------------------------------------------

Expand Down Expand Up @@ -142,7 +137,9 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [(master_doc, 'testbook.tex', 'testbook Documentation', 'nteract team', 'manual')]
latex_documents = [
(master_doc, 'testbook.tex', 'testbook Documentation', 'nteract team', 'manual')
]


# -- Options for manual page output ---------------------------------------
Expand Down Expand Up @@ -170,4 +167,7 @@
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'python': ('https://docs.python.org/', None)}

# Generate heading anchors for h1, h2 and h3.
myst_heading_anchors = 3
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
[![Coverage Status][codecov-badge]][codecov-link]
[![Documentation Status][rtd-badge]][rtd-link]
[![PyPI][pypi-badge]][pypi-link]
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![image](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![image](https://img.shields.io/pypi/l/testbook.svg)](https://github.com/astral-sh/testbook/blob/main/LICENSE)
[![image](https://img.shields.io/pypi/pyversions/testbook.svg)](https://pypi.python.org/pypi/testbook)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)

**testbook** is a unit testing framework for testing code in Jupyter Notebooks.
Expand Down Expand Up @@ -41,9 +41,9 @@ def test_func(tb):
## Features

- Write conventional unit tests for Jupyter Notebooks
- [Execute all or some specific cells before unit test](usage/index.html#using-execute-to-control-which-cells-are-executed-before-test)
- [Share kernel context across multiple tests](usage/index.html#share-kernel-context-across-multiple-tests) (using pytest fixtures)
- [Support for patching objects](usage/index.html#support-for-patching-objects)
- [Execute all or some specific cells before unit test](usage/index.md#using-execute-to-control-which-cells-are-executed-before-test)
- [Share kernel context across multiple tests](usage/index.md#share-kernel-context-across-multiple-tests) (using pytest fixtures)
- [Support for patching objects](usage/index.md#support-for-patching-objects)
- Inject code into Jupyter notebooks
- Works with any unit testing library - unittest, pytest or nose

Expand Down
3 changes: 0 additions & 3 deletions docs/requirements-doc.txt

This file was deleted.

3 changes: 2 additions & 1 deletion examples/dataframe-example/dataframe_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from testbook import testbook


@testbook('./dataframe-assertion-example.ipynb')
def test_dataframe_manipulation(tb):
tb.execute_cell('imports')
Expand All @@ -15,4 +16,4 @@ def test_dataframe_manipulation(tb):
tb.execute_cell('manipulation')

# Inject assertion into notebook
tb.inject("assert len(df) == 1")
tb.inject('assert len(df) == 1')
3 changes: 2 additions & 1 deletion examples/requests-example/requests_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from testbook import testbook


@testbook('./requests-test.ipynb', execute=True)
def test_get_details(tb):
with tb.patch('requests.get') as mock_get:
get_details = tb.ref('get_details') # get reference to function
get_details = tb.ref('get_details') # get reference to function
get_details('https://my-api.com')

mock_get.assert_called_with('https://my-api.com')
1 change: 1 addition & 0 deletions examples/stdout-example/stdout_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from testbook import testbook


@testbook('stdout-assertion-example.ipynb', execute=True)
def test_stdout(tb):
assert tb.cell_output_text(1) == 'hello world!'
Expand Down
Loading