Skip to content

Commit

Permalink
Merge pull request #252 from blink1073/include-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Mar 9, 2022
2 parents c15bcc9 + a7502cf commit 7c4543f
Show file tree
Hide file tree
Showing 53 changed files with 57 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: List dependencies
run: pip list
- name: Run tests
run: py.test nbformat/tests -v --cov=nbformat
run: pytest -v --cov=nbformat
- name: Check manfest
run: check-manifest -v
- name: Coverage
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ include RELEASING.md
include MANIFEST.in
recursive-include nbformat *.txt
recursive-include nbformat *.json
recursive-exclude nbformat/tests *.*
recursive-include tests *.*
exclude scripts/jupyter-trust

# Javascript
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To enable fast validation with `fastjsonschema`, set the environment variable `N

## Python Version Support

This library supported python 2.7 and python 3.5+ for `4.x.x` releases. With python 2's end-of-life nbformat `5.x.x` is now python 3.5+ only. Support for 3.5 will be dropped when it's officially sunset by the python organization.
This library supported Python 2.7 and Python 3.5+ for `4.x.x` releases. With Python 2's end-of-life nbformat `5.x.x` supported Python 3 only. Support for Python 3.x versions will be dropped when they are officially sunset by the python organization.

## Contributing

Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
packages.append(d[len(here)+1:].replace(os.path.sep, '.'))

package_data = {
'nbformat.tests' : [
'*.ipynb',
],
'nbformat.v3' : [
'nbformat.v3*.schema.json',
],
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.
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.
4 changes: 2 additions & 2 deletions nbformat/tests/test_api.py → tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from jsonschema import ValidationError

from tempfile import TemporaryDirectory
from ..reader import get_version
from ..validator import isvalid
from nbformat.reader import get_version
from nbformat.validator import isvalid
from nbformat import read, current_nbformat, writes, write


Expand Down
8 changes: 4 additions & 4 deletions nbformat/tests/test_convert.py → tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from .base import TestsBase

from ..converter import convert
from ..reader import read, get_version
from ..validator import isvalid, validate, ValidationError
from .. import current_nbformat
from nbformat.converter import convert
from nbformat.reader import read, get_version
from nbformat.validator import isvalid, validate, ValidationError
from nbformat import current_nbformat


class TestConvert(TestsBase):
Expand Down
2 changes: 1 addition & 1 deletion nbformat/tests/test_nbformat.py → tests/test_nbformat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from nbformat import read
from ..validator import ValidationError
from nbformat.validator import ValidationError


def test_read_invalid_iowrapper(tmpdir):
Expand Down
6 changes: 3 additions & 3 deletions nbformat/tests/test_reader.py → tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from .base import TestsBase

from ..reader import read, get_version
from ..validator import ValidationError
from nbformat.reader import read, get_version
from nbformat.validator import ValidationError

#-----------------------------------------------------------------------------
# Classes and functions
Expand Down Expand Up @@ -47,4 +47,4 @@ def test_read_fails_on_missing_worksheet_cells(self):
with self.fopen(u'test3_worksheet_with_no_cells.ipynb', u'r') as f:
with self.assertRaisesRegex(ValidationError, r'cells'):
nb = read(f)


File renamed without changes.
4 changes: 2 additions & 2 deletions nbformat/tests/test_validator.py → tests/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from .base import TestsBase
from jsonschema import ValidationError
from nbformat import read
from ..validator import isvalid, validate, iter_validate
from ..json_compat import VALIDATORS
from nbformat.validator import isvalid, validate, iter_validate
from nbformat.json_compat import VALIDATORS

import pytest

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nbformat/v1/tests/nbexamples.py → tests/v1/nbexamples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..nbbase import (
from nbformat.v1.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_notebook
)
Expand Down
2 changes: 1 addition & 1 deletion nbformat/v1/tests/test_json.py → tests/v1/test_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase

from ..nbjson import reads, writes
from nbformat.v1.nbjson import reads, writes
from .nbexamples import nb0


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase

from ..nbbase import (
from nbformat.v1.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_notebook
)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions nbformat/v2/tests/nbexamples.py → tests/v2/nbexamples.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from ..._compat import encodebytes
from ..nbbase import (
from nbformat._compat import encodebytes
from nbformat.v2.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output,
new_metadata, new_author
Expand Down
2 changes: 1 addition & 1 deletion nbformat/v2/tests/test_json.py → tests/v2/test_json.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pprint
from unittest import TestCase

from ..nbjson import reads, writes
from nbformat.v2.nbjson import reads, writes
from .nbexamples import nb0


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase

from ..nbbase import (
from nbformat.v2.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output,
new_author, new_metadata
Expand Down
4 changes: 2 additions & 2 deletions nbformat/v2/tests/test_nbpy.py → tests/v2/test_nbpy.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from unittest import TestCase

from ..nbbase import (
from nbformat.v2.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook
)

from ..nbpy import reads, writes
from nbformat.v2.nbpy import reads, writes
from .nbexamples import nb0, nb0_py


Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions nbformat/v3/tests/formattest.py → tests/v3/formattest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

pjoin = os.path.join

from ..nbbase import (
from nbformat.v3.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook
)

from ..nbpy import reads, writes, read, write
from nbformat.v3.nbpy import reads, writes, read, write
from .nbexamples import nb0, nb0_py


Expand Down
4 changes: 2 additions & 2 deletions nbformat/v3/tests/nbexamples.py → tests/v3/nbexamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import os

from ..._compat import encodebytes
from ..nbbase import (
from nbformat._compat import encodebytes
from nbformat.v3.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output,
new_metadata, new_author, new_heading_cell, nbformat, nbformat_minor
Expand Down
8 changes: 4 additions & 4 deletions nbformat/v3/tests/test_json.py → tests/v3/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import json
from unittest import TestCase

from ..._compat import decodebytes
from ..nbjson import reads, writes
from ..nbbase import from_dict
from .. import nbjson
from nbformat._compat import decodebytes
from nbformat.v3.nbjson import reads, writes
from nbformat.v3.nbbase import from_dict
from nbformat.v3 import nbjson
from .nbexamples import nb0

from . import formattest
Expand Down
2 changes: 1 addition & 1 deletion nbformat/v3/tests/test_misc.py → tests/v3/test_misc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from unittest import TestCase

from .. import parse_filename
from nbformat.v3 import parse_filename


class MiscTests(TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase

from ..nbbase import (
from nbformat.v3.nbbase import (
NotebookNode,
new_code_cell, new_text_cell, new_worksheet, new_notebook, new_output,
new_author, new_metadata, new_heading_cell, nbformat
Expand Down
2 changes: 1 addition & 1 deletion nbformat/v3/tests/test_nbpy.py → tests/v3/test_nbpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from . import formattest

from .. import nbpy
from nbformat.v3 import nbpy
from .nbexamples import nb0, nb0_py


Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions nbformat/v4/tests/nbexamples.py → tests/v4/nbexamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import os

from ..._compat import encodebytes
from ..nbbase import (
from nbformat._compat import encodebytes
from nbformat.v4.nbbase import (
new_code_cell, new_markdown_cell, new_notebook,
new_output, new_raw_cell
)
Expand Down
13 changes: 7 additions & 6 deletions nbformat/v4/tests/test_convert.py → tests/v4/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

from unittest import mock
from nbformat import validate
from .. import convert
from ..nbjson import reads
from nbformat.v4 import convert
from nbformat.v4.nbjson import reads
import pytest
from nbformat import ValidationError

from . import nbexamples
from nbformat.v3.tests import nbexamples as v3examples
from ..v3 import nbexamples as v3examples
from nbformat import v3, v4

def test_upgrade_notebook():
Expand Down Expand Up @@ -81,8 +81,9 @@ def test_downgrade_heading():

def test_upgrade_v4_to_4_dot_5():
here = os.path.dirname(__file__)
with io.open(os.path.join(here, os.pardir, os.pardir, 'tests', "test4.ipynb"), encoding='utf-8') as f:
with io.open(os.path.join(here, os.pardir, "test4.ipynb"), encoding='utf-8') as f:
nb = reads(f.read())

assert nb['nbformat_minor'] == 0
validate(nb)
assert nb.cells[0].get('id') is None
Expand All @@ -94,8 +95,8 @@ def test_upgrade_v4_to_4_dot_5():

def test_upgrade_without_nbminor_version():
here = os.path.dirname(__file__)
with io.open(os.path.join(here, os.pardir, os.pardir, 'tests', "no_min_version.ipynb"), encoding='utf-8') as f:
with io.open(os.path.join(here, os.pardir, "no_min_version.ipynb"), encoding='utf-8') as f:
nb = reads(f.read())

with pytest.raises(ValidationError):
convert.upgrade(nb)
convert.upgrade(nb)
16 changes: 10 additions & 6 deletions nbformat/v4/tests/test_json.py → tests/v4/test_json.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
import json
import sys
from unittest import TestCase

from ..._compat import decodebytes
from ..nbjson import reads, writes
from .. import nbjson, nbformat, nbformat_minor
from nbformat._compat import decodebytes
from nbformat.v4.nbjson import reads, writes
from nbformat.v4 import nbjson, nbformat, nbformat_minor
from .nbexamples import nb0

from . import formattest


BASE_PATH = os.path.join(sys.modules['nbformat'].__path__[0], 'v4')


class TestJSON(formattest.NBFormatTest, TestCase):

nb0_ref = None
Expand Down Expand Up @@ -106,16 +110,16 @@ def test_latest_schema_matches(self):

def test_base_version_matches_latest(self):
"""Test to ensure latest version file matches latest verison"""
with open(os.path.join(os.path.dirname(__file__), '..', 'nbformat.v4.schema.json'), 'r') as schema_file:
with open(os.path.join(BASE_PATH, 'nbformat.v4.schema.json'), 'r') as schema_file:
latest_schema = json.load(schema_file)
with open(os.path.join(os.path.dirname(__file__), '..', 'nbformat.v{major}.{minor}.schema.json'.format(
with open(os.path.join(BASE_PATH, 'nbformat.v{major}.{minor}.schema.json'.format(
major=nbformat, minor=nbformat_minor)), 'r') as schema_file:
ver_schema = json.load(schema_file)
assert latest_schema == ver_schema

def test_latest_matches_nbformat(self):
"""Test to ensure that the nbformat version matches the description of the latest schema"""
with open(os.path.join(os.path.dirname(__file__), '..', 'nbformat.v4.schema.json'), 'r') as schema_file:
with open(os.path.join(BASE_PATH, 'nbformat.v4.schema.json'), 'r') as schema_file:
schema = json.load(schema_file)
assert schema['description'] == 'Jupyter Notebook v{major}.{minor} JSON schema.'.format(
major=nbformat, minor=nbformat_minor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Tests for the Python API for composing notebook elements"""

from nbformat.validator import isvalid, validate, ValidationError
from ..nbbase import (
from nbformat.v4.nbbase import (
NotebookNode, nbformat,
new_code_cell, new_markdown_cell, new_notebook,
new_output, new_raw_cell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pytest

from nbformat.validator import validate, ValidationError
from ..nbjson import reads
from ..nbbase import (
from nbformat.v4.nbjson import reads
from nbformat.v4.nbbase import (
nbformat,
new_code_cell, new_markdown_cell, new_notebook,
new_output, new_raw_cell,
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 7c4543f

Please sign in to comment.