From e0800d6137cf778738b0ce78e10c1dbd77aa035b Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 2 Mar 2022 08:17:33 -0600 Subject: [PATCH] Include tests in sdist but not wheel --- .github/workflows/tests.yml | 2 +- MANIFEST.in | 2 +- setup.py | 3 --- {nbformat/tests => tests}/__init__.py | 0 {nbformat/tests => tests}/base.py | 0 {nbformat/tests => tests}/invalid.ipynb | 0 {nbformat/tests => tests}/invalid_cell_id.ipynb | 0 .../tests => tests}/invalid_unique_cell_id.ipynb | 0 {nbformat/tests => tests}/many_tracebacks.ipynb | 0 {nbformat/tests => tests}/no_min_version.ipynb | 0 {nbformat/tests => tests}/test2.ipynb | 0 {nbformat/tests => tests}/test3.ipynb | 0 .../tests => tests}/test3_no_metadata.ipynb | 0 .../tests => tests}/test3_no_worksheets.ipynb | 0 .../test3_worksheet_with_no_cells.ipynb | 0 {nbformat/tests => tests}/test4.ipynb | 0 {nbformat/tests => tests}/test4custom.ipynb | 0 {nbformat/tests => tests}/test4docinfo.ipynb | 0 .../tests => tests}/test4jupyter_metadata.ipynb | 0 .../test4jupyter_metadata_timings.ipynb | 0 {nbformat/tests => tests}/test4plus.ipynb | 0 {nbformat/tests => tests}/test_api.py | 4 ++-- {nbformat/tests => tests}/test_convert.py | 8 ++++---- {nbformat/tests => tests}/test_nbformat.py | 2 +- {nbformat/tests => tests}/test_reader.py | 6 +++--- {nbformat/tests => tests}/test_sign.py | 0 {nbformat/tests => tests}/test_validator.py | 4 ++-- {nbformat/v1/tests => tests/v1}/__init__.py | 0 {nbformat/v1/tests => tests/v1}/nbexamples.py | 2 +- {nbformat/v1/tests => tests/v1}/test_json.py | 2 +- {nbformat/v1/tests => tests/v1}/test_nbbase.py | 2 +- {nbformat/v2/tests => tests/v2}/__init__.py | 0 {nbformat/v2/tests => tests/v2}/nbexamples.py | 4 ++-- {nbformat/v2/tests => tests/v2}/test_json.py | 2 +- {nbformat/v2/tests => tests/v2}/test_nbbase.py | 2 +- {nbformat/v2/tests => tests/v2}/test_nbpy.py | 4 ++-- {nbformat/v3/tests => tests/v3}/__init__.py | 0 {nbformat/v3/tests => tests/v3}/formattest.py | 4 ++-- {nbformat/v3/tests => tests/v3}/nbexamples.py | 4 ++-- {nbformat/v3/tests => tests/v3}/test_json.py | 8 ++++---- {nbformat/v3/tests => tests/v3}/test_misc.py | 2 +- {nbformat/v3/tests => tests/v3}/test_nbbase.py | 2 +- {nbformat/v3/tests => tests/v3}/test_nbpy.py | 2 +- {nbformat/v4/tests => tests/v4}/__init__.py | 0 {nbformat/v4/tests => tests/v4}/formattest.py | 0 {nbformat/v4/tests => tests/v4}/nbexamples.py | 4 ++-- {nbformat/v4/tests => tests/v4}/test_convert.py | 13 +++++++------ {nbformat/v4/tests => tests/v4}/test_json.py | 16 ++++++++++------ {nbformat/v4/tests => tests/v4}/test_nbbase.py | 2 +- {nbformat/v4/tests => tests/v4}/test_validate.py | 4 ++-- .../tests => tests}/v4_5_invalid_metadata.ipynb | 0 {nbformat/tests => tests}/v4_5_no_cell_id.ipynb | 0 52 files changed, 56 insertions(+), 54 deletions(-) rename {nbformat/tests => tests}/__init__.py (100%) rename {nbformat/tests => tests}/base.py (100%) rename {nbformat/tests => tests}/invalid.ipynb (100%) rename {nbformat/tests => tests}/invalid_cell_id.ipynb (100%) rename {nbformat/tests => tests}/invalid_unique_cell_id.ipynb (100%) rename {nbformat/tests => tests}/many_tracebacks.ipynb (100%) rename {nbformat/tests => tests}/no_min_version.ipynb (100%) rename {nbformat/tests => tests}/test2.ipynb (100%) rename {nbformat/tests => tests}/test3.ipynb (100%) rename {nbformat/tests => tests}/test3_no_metadata.ipynb (100%) rename {nbformat/tests => tests}/test3_no_worksheets.ipynb (100%) rename {nbformat/tests => tests}/test3_worksheet_with_no_cells.ipynb (100%) rename {nbformat/tests => tests}/test4.ipynb (100%) rename {nbformat/tests => tests}/test4custom.ipynb (100%) rename {nbformat/tests => tests}/test4docinfo.ipynb (100%) rename {nbformat/tests => tests}/test4jupyter_metadata.ipynb (100%) rename {nbformat/tests => tests}/test4jupyter_metadata_timings.ipynb (100%) rename {nbformat/tests => tests}/test4plus.ipynb (100%) rename {nbformat/tests => tests}/test_api.py (97%) rename {nbformat/tests => tests}/test_convert.py (92%) rename {nbformat/tests => tests}/test_nbformat.py (96%) rename {nbformat/tests => tests}/test_reader.py (94%) rename {nbformat/tests => tests}/test_sign.py (100%) rename {nbformat/tests => tests}/test_validator.py (98%) rename {nbformat/v1/tests => tests/v1}/__init__.py (100%) rename {nbformat/v1/tests => tests/v1}/nbexamples.py (92%) rename {nbformat/v1/tests => tests/v1}/test_json.py (80%) rename {nbformat/v1/tests => tests/v1}/test_nbbase.py (97%) rename {nbformat/v2/tests => tests/v2}/__init__.py (100%) rename {nbformat/v2/tests => tests/v2}/nbexamples.py (96%) rename {nbformat/v2/tests => tests/v2}/test_json.py (95%) rename {nbformat/v2/tests => tests/v2}/test_nbbase.py (99%) rename {nbformat/v2/tests => tests/v2}/test_nbpy.py (77%) rename {nbformat/v3/tests => tests/v3}/__init__.py (100%) rename {nbformat/v3/tests => tests/v3}/formattest.py (94%) rename {nbformat/v3/tests => tests/v3}/nbexamples.py (97%) rename {nbformat/v3/tests => tests/v3}/test_json.py (95%) rename {nbformat/v3/tests => tests/v3}/test_misc.py (96%) rename {nbformat/v3/tests => tests/v3}/test_nbbase.py (99%) rename {nbformat/v3/tests => tests/v3}/test_nbpy.py (97%) rename {nbformat/v4/tests => tests/v4}/__init__.py (100%) rename {nbformat/v4/tests => tests/v4}/formattest.py (100%) rename {nbformat/v4/tests => tests/v4}/nbexamples.py (97%) rename {nbformat/v4/tests => tests/v4}/test_convert.py (88%) rename {nbformat/v4/tests => tests/v4}/test_json.py (89%) rename {nbformat/v4/tests => tests/v4}/test_nbbase.py (98%) rename {nbformat/v4/tests => tests/v4}/test_validate.py (97%) rename {nbformat/tests => tests}/v4_5_invalid_metadata.ipynb (100%) rename {nbformat/tests => tests}/v4_5_no_cell_id.ipynb (100%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 95525811..91916f79 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in index 1235b07a..fb8702ca 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/setup.py b/setup.py index e8b5476f..9124e402 100644 --- a/setup.py +++ b/setup.py @@ -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', ], diff --git a/nbformat/tests/__init__.py b/tests/__init__.py similarity index 100% rename from nbformat/tests/__init__.py rename to tests/__init__.py diff --git a/nbformat/tests/base.py b/tests/base.py similarity index 100% rename from nbformat/tests/base.py rename to tests/base.py diff --git a/nbformat/tests/invalid.ipynb b/tests/invalid.ipynb similarity index 100% rename from nbformat/tests/invalid.ipynb rename to tests/invalid.ipynb diff --git a/nbformat/tests/invalid_cell_id.ipynb b/tests/invalid_cell_id.ipynb similarity index 100% rename from nbformat/tests/invalid_cell_id.ipynb rename to tests/invalid_cell_id.ipynb diff --git a/nbformat/tests/invalid_unique_cell_id.ipynb b/tests/invalid_unique_cell_id.ipynb similarity index 100% rename from nbformat/tests/invalid_unique_cell_id.ipynb rename to tests/invalid_unique_cell_id.ipynb diff --git a/nbformat/tests/many_tracebacks.ipynb b/tests/many_tracebacks.ipynb similarity index 100% rename from nbformat/tests/many_tracebacks.ipynb rename to tests/many_tracebacks.ipynb diff --git a/nbformat/tests/no_min_version.ipynb b/tests/no_min_version.ipynb similarity index 100% rename from nbformat/tests/no_min_version.ipynb rename to tests/no_min_version.ipynb diff --git a/nbformat/tests/test2.ipynb b/tests/test2.ipynb similarity index 100% rename from nbformat/tests/test2.ipynb rename to tests/test2.ipynb diff --git a/nbformat/tests/test3.ipynb b/tests/test3.ipynb similarity index 100% rename from nbformat/tests/test3.ipynb rename to tests/test3.ipynb diff --git a/nbformat/tests/test3_no_metadata.ipynb b/tests/test3_no_metadata.ipynb similarity index 100% rename from nbformat/tests/test3_no_metadata.ipynb rename to tests/test3_no_metadata.ipynb diff --git a/nbformat/tests/test3_no_worksheets.ipynb b/tests/test3_no_worksheets.ipynb similarity index 100% rename from nbformat/tests/test3_no_worksheets.ipynb rename to tests/test3_no_worksheets.ipynb diff --git a/nbformat/tests/test3_worksheet_with_no_cells.ipynb b/tests/test3_worksheet_with_no_cells.ipynb similarity index 100% rename from nbformat/tests/test3_worksheet_with_no_cells.ipynb rename to tests/test3_worksheet_with_no_cells.ipynb diff --git a/nbformat/tests/test4.ipynb b/tests/test4.ipynb similarity index 100% rename from nbformat/tests/test4.ipynb rename to tests/test4.ipynb diff --git a/nbformat/tests/test4custom.ipynb b/tests/test4custom.ipynb similarity index 100% rename from nbformat/tests/test4custom.ipynb rename to tests/test4custom.ipynb diff --git a/nbformat/tests/test4docinfo.ipynb b/tests/test4docinfo.ipynb similarity index 100% rename from nbformat/tests/test4docinfo.ipynb rename to tests/test4docinfo.ipynb diff --git a/nbformat/tests/test4jupyter_metadata.ipynb b/tests/test4jupyter_metadata.ipynb similarity index 100% rename from nbformat/tests/test4jupyter_metadata.ipynb rename to tests/test4jupyter_metadata.ipynb diff --git a/nbformat/tests/test4jupyter_metadata_timings.ipynb b/tests/test4jupyter_metadata_timings.ipynb similarity index 100% rename from nbformat/tests/test4jupyter_metadata_timings.ipynb rename to tests/test4jupyter_metadata_timings.ipynb diff --git a/nbformat/tests/test4plus.ipynb b/tests/test4plus.ipynb similarity index 100% rename from nbformat/tests/test4plus.ipynb rename to tests/test4plus.ipynb diff --git a/nbformat/tests/test_api.py b/tests/test_api.py similarity index 97% rename from nbformat/tests/test_api.py rename to tests/test_api.py index dce53467..f94a6ec3 100644 --- a/nbformat/tests/test_api.py +++ b/tests/test_api.py @@ -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 diff --git a/nbformat/tests/test_convert.py b/tests/test_convert.py similarity index 92% rename from nbformat/tests/test_convert.py rename to tests/test_convert.py index 98c44a62..580597bc 100644 --- a/nbformat/tests/test_convert.py +++ b/tests/test_convert.py @@ -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): diff --git a/nbformat/tests/test_nbformat.py b/tests/test_nbformat.py similarity index 96% rename from nbformat/tests/test_nbformat.py rename to tests/test_nbformat.py index f65852eb..714179d4 100644 --- a/nbformat/tests/test_nbformat.py +++ b/tests/test_nbformat.py @@ -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): diff --git a/nbformat/tests/test_reader.py b/tests/test_reader.py similarity index 94% rename from nbformat/tests/test_reader.py rename to tests/test_reader.py index 5130c94f..76e5a332 100644 --- a/nbformat/tests/test_reader.py +++ b/tests/test_reader.py @@ -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 @@ -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) - \ No newline at end of file + diff --git a/nbformat/tests/test_sign.py b/tests/test_sign.py similarity index 100% rename from nbformat/tests/test_sign.py rename to tests/test_sign.py diff --git a/nbformat/tests/test_validator.py b/tests/test_validator.py similarity index 98% rename from nbformat/tests/test_validator.py rename to tests/test_validator.py index f4caabf5..46804a21 100644 --- a/nbformat/tests/test_validator.py +++ b/tests/test_validator.py @@ -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 diff --git a/nbformat/v1/tests/__init__.py b/tests/v1/__init__.py similarity index 100% rename from nbformat/v1/tests/__init__.py rename to tests/v1/__init__.py diff --git a/nbformat/v1/tests/nbexamples.py b/tests/v1/nbexamples.py similarity index 92% rename from nbformat/v1/tests/nbexamples.py rename to tests/v1/nbexamples.py index e07ac487..d6a797f8 100644 --- a/nbformat/v1/tests/nbexamples.py +++ b/tests/v1/nbexamples.py @@ -1,4 +1,4 @@ -from ..nbbase import ( +from nbformat.v1.nbbase import ( NotebookNode, new_code_cell, new_text_cell, new_notebook ) diff --git a/nbformat/v1/tests/test_json.py b/tests/v1/test_json.py similarity index 80% rename from nbformat/v1/tests/test_json.py rename to tests/v1/test_json.py index ec7c3f92..54cf1968 100644 --- a/nbformat/v1/tests/test_json.py +++ b/tests/v1/test_json.py @@ -1,6 +1,6 @@ from unittest import TestCase -from ..nbjson import reads, writes +from nbformat.v1.nbjson import reads, writes from .nbexamples import nb0 diff --git a/nbformat/v1/tests/test_nbbase.py b/tests/v1/test_nbbase.py similarity index 97% rename from nbformat/v1/tests/test_nbbase.py rename to tests/v1/test_nbbase.py index 63310602..60371b61 100644 --- a/nbformat/v1/tests/test_nbbase.py +++ b/tests/v1/test_nbbase.py @@ -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 ) diff --git a/nbformat/v2/tests/__init__.py b/tests/v2/__init__.py similarity index 100% rename from nbformat/v2/tests/__init__.py rename to tests/v2/__init__.py diff --git a/nbformat/v2/tests/nbexamples.py b/tests/v2/nbexamples.py similarity index 96% rename from nbformat/v2/tests/nbexamples.py rename to tests/v2/nbexamples.py index f5f642db..0c0f83fd 100644 --- a/nbformat/v2/tests/nbexamples.py +++ b/tests/v2/nbexamples.py @@ -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 diff --git a/nbformat/v2/tests/test_json.py b/tests/v2/test_json.py similarity index 95% rename from nbformat/v2/tests/test_json.py rename to tests/v2/test_json.py index 453d6c42..f51e5276 100644 --- a/nbformat/v2/tests/test_json.py +++ b/tests/v2/test_json.py @@ -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 diff --git a/nbformat/v2/tests/test_nbbase.py b/tests/v2/test_nbbase.py similarity index 99% rename from nbformat/v2/tests/test_nbbase.py rename to tests/v2/test_nbbase.py index 62d49bf1..6cb87a16 100644 --- a/nbformat/v2/tests/test_nbbase.py +++ b/tests/v2/test_nbbase.py @@ -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 diff --git a/nbformat/v2/tests/test_nbpy.py b/tests/v2/test_nbpy.py similarity index 77% rename from nbformat/v2/tests/test_nbpy.py rename to tests/v2/test_nbpy.py index 956c5a61..fb13598a 100644 --- a/nbformat/v2/tests/test_nbpy.py +++ b/tests/v2/test_nbpy.py @@ -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 diff --git a/nbformat/v3/tests/__init__.py b/tests/v3/__init__.py similarity index 100% rename from nbformat/v3/tests/__init__.py rename to tests/v3/__init__.py diff --git a/nbformat/v3/tests/formattest.py b/tests/v3/formattest.py similarity index 94% rename from nbformat/v3/tests/formattest.py rename to tests/v3/formattest.py index e8667586..6ef4081c 100644 --- a/nbformat/v3/tests/formattest.py +++ b/tests/v3/formattest.py @@ -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 diff --git a/nbformat/v3/tests/nbexamples.py b/tests/v3/nbexamples.py similarity index 97% rename from nbformat/v3/tests/nbexamples.py rename to tests/v3/nbexamples.py index bdafc75c..d635ca1c 100644 --- a/nbformat/v3/tests/nbexamples.py +++ b/tests/v3/nbexamples.py @@ -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 diff --git a/nbformat/v3/tests/test_json.py b/tests/v3/test_json.py similarity index 95% rename from nbformat/v3/tests/test_json.py rename to tests/v3/test_json.py index bcf72821..b8830b79 100644 --- a/nbformat/v3/tests/test_json.py +++ b/tests/v3/test_json.py @@ -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 diff --git a/nbformat/v3/tests/test_misc.py b/tests/v3/test_misc.py similarity index 96% rename from nbformat/v3/tests/test_misc.py rename to tests/v3/test_misc.py index 6a3e6633..0d2b6631 100644 --- a/nbformat/v3/tests/test_misc.py +++ b/tests/v3/test_misc.py @@ -1,7 +1,7 @@ import os from unittest import TestCase -from .. import parse_filename +from nbformat.v3 import parse_filename class MiscTests(TestCase): diff --git a/nbformat/v3/tests/test_nbbase.py b/tests/v3/test_nbbase.py similarity index 99% rename from nbformat/v3/tests/test_nbbase.py rename to tests/v3/test_nbbase.py index 44afcfcb..63f5c8b9 100644 --- a/nbformat/v3/tests/test_nbbase.py +++ b/tests/v3/test_nbbase.py @@ -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 diff --git a/nbformat/v3/tests/test_nbpy.py b/tests/v3/test_nbpy.py similarity index 97% rename from nbformat/v3/tests/test_nbpy.py rename to tests/v3/test_nbpy.py index 12f8d671..da2c669d 100644 --- a/nbformat/v3/tests/test_nbpy.py +++ b/tests/v3/test_nbpy.py @@ -4,7 +4,7 @@ from . import formattest -from .. import nbpy +from nbformat.v3 import nbpy from .nbexamples import nb0, nb0_py diff --git a/nbformat/v4/tests/__init__.py b/tests/v4/__init__.py similarity index 100% rename from nbformat/v4/tests/__init__.py rename to tests/v4/__init__.py diff --git a/nbformat/v4/tests/formattest.py b/tests/v4/formattest.py similarity index 100% rename from nbformat/v4/tests/formattest.py rename to tests/v4/formattest.py diff --git a/nbformat/v4/tests/nbexamples.py b/tests/v4/nbexamples.py similarity index 97% rename from nbformat/v4/tests/nbexamples.py rename to tests/v4/nbexamples.py index 9602740b..3e7159d2 100644 --- a/nbformat/v4/tests/nbexamples.py +++ b/tests/v4/nbexamples.py @@ -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 ) diff --git a/nbformat/v4/tests/test_convert.py b/tests/v4/test_convert.py similarity index 88% rename from nbformat/v4/tests/test_convert.py rename to tests/v4/test_convert.py index 3e73e4a7..f515ff94 100644 --- a/nbformat/v4/tests/test_convert.py +++ b/tests/v4/test_convert.py @@ -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(): @@ -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 @@ -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) \ No newline at end of file + convert.upgrade(nb) diff --git a/nbformat/v4/tests/test_json.py b/tests/v4/test_json.py similarity index 89% rename from nbformat/v4/tests/test_json.py rename to tests/v4/test_json.py index 359a988a..51d932fd 100644 --- a/nbformat/v4/tests/test_json.py +++ b/tests/v4/test_json.py @@ -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 @@ -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 diff --git a/nbformat/v4/tests/test_nbbase.py b/tests/v4/test_nbbase.py similarity index 98% rename from nbformat/v4/tests/test_nbbase.py rename to tests/v4/test_nbbase.py index 5bfbff45..9d3af48c 100644 --- a/nbformat/v4/tests/test_nbbase.py +++ b/tests/v4/test_nbbase.py @@ -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, diff --git a/nbformat/v4/tests/test_validate.py b/tests/v4/test_validate.py similarity index 97% rename from nbformat/v4/tests/test_validate.py rename to tests/v4/test_validate.py index a3f98371..4000acd5 100644 --- a/nbformat/v4/tests/test_validate.py +++ b/tests/v4/test_validate.py @@ -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, diff --git a/nbformat/tests/v4_5_invalid_metadata.ipynb b/tests/v4_5_invalid_metadata.ipynb similarity index 100% rename from nbformat/tests/v4_5_invalid_metadata.ipynb rename to tests/v4_5_invalid_metadata.ipynb diff --git a/nbformat/tests/v4_5_no_cell_id.ipynb b/tests/v4_5_no_cell_id.ipynb similarity index 100% rename from nbformat/tests/v4_5_no_cell_id.ipynb rename to tests/v4_5_no_cell_id.ipynb