Repository: cfpb/wagtail-inventory (language: python)

Issue:
Draft: Wagtail 4.2 support
- Updated tox testing and workflow actions
- Removed support for Wagtail versions < 4.1
- Suppress warnings
- Code cleanup

All tests run OK

```
Found 19 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
...................
----------------------------------------------------------------------
Ran 19 tests in 0.920s

OK
```


Discussion / hints:

Fix patch:
diff --git a/.flake8 b/.flake8
deleted file mode 100644
index 220df43..0000000
--- a/.flake8
+++ /dev/null
@@ -1,21 +0,0 @@
-[flake8]
-max-line-length = 79
-select = C,E,F,W,B,B950
-ignore =
-    # black https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
-    E203, E501
-    # There's nothing wrong with assigning lambdas
-    E731,
-    # PEP8 weakly recommends Knuth-style line breaks before binary
-    # operators
-    W503, W504
-extend-exclude =
-    # These are directories that it's a waste of time to traverse
-    .venv,
-    docs,
-    venv,
-
-    # Generated migration files will throw errors. We need to find a way
-    # to exclude django-generated migrations while including
-    # manually-written migrations.
-    **/migrations/*.py,
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e231216..0ff2f24 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -7,9 +7,9 @@ jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v1
+    - uses: actions/checkout@v3
     - name: Set up Python
-      uses: actions/setup-python@v1
+      uses: actions/setup-python@v4
       with:
         python-version: 3.8
     - name: Install dependencies
diff --git a/.gitignore b/.gitignore
index 49d89e6..da7ad8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,6 +50,7 @@ __pycache__/
 .env
 .eggs
 .python-version
+build/
 
 # Django #
 #################
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 67e4601..a9ee3dc 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -5,7 +5,7 @@ repos:
     - id: black
       args: ["wagtailinventory", "setup.py", "--line-length=79"]
       exclude: migrations
--   repo: https://gitlab.com/pycqa/flake8
+-   repo: https://github.com/pycqa/flake8
     rev: 4.0.1
     hooks:
     - id: flake8
diff --git a/README.rst b/README.rst
index 9fdcda8..e8b8f7a 100644
--- a/README.rst
+++ b/README.rst
@@ -1,9 +1,6 @@
 .. image:: https://github.com/cfpb/wagtail-inventory/workflows/test/badge.svg
   :alt: Build Status
   :target: https://github.com/cfpb/wagtail-inventory/actions/workflows/test.yml
-.. image:: https://coveralls.io/repos/github/cfpb/wagtail-inventory/badge.svg?branch=main
-  :alt: Coverage Status
-  :target: https://coveralls.io/github/cfpb/wagtail-inventory?branch=main
 
 wagtail-inventory
 =================
@@ -52,8 +49,8 @@ Compatibility
 This code has been tested for compatibility with:
 
 * Python 3.8+
-* Django 3.2 (LTS), 4.0, 4.1
-* Wagtail 2.15 (LTS), 3.0, 4.0, 4.1 (LTS)
+* Django 3.2 (LTS), 4.1
+* Wagtail 3.0, 4.1 (LTS), 4.2
 
 It should be compatible with all intermediate versions, as well.
 If you find that it is not, please `file an issue <https://github.com/cfpb/wagtail-inventory/issues/new>`_.
diff --git a/pyproject.toml b/pyproject.toml
index 2d6007c..29a8bc7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,52 @@
+[project]
+name = "wagtail-inventory"
+version = "1.6.0"
+description = "Lookup Wagtail pages by block content"
+readme = "README.rst"
+requires-python = ">=3.8"
+license = {text = "CC0"}
+authors = [
+    {name = "CFPB", email = "tech@cfpb.gov" }
+]
+dependencies = [
+    "tqdm>=4.15.0,<5",
+    "wagtail>=3",
+]
+classifiers = [
+    "Framework :: Django",
+    "Framework :: Django :: 3.2",
+    "Framework :: Django :: 4",
+    "Framework :: Wagtail",
+    "Framework :: Wagtail :: 3",
+    "Framework :: Wagtail :: 4",
+    "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
+    "License :: Public Domain",
+    "Programming Language :: Python",
+    "Programming Language :: Python :: 3",
+]
+
+[project.optional-dependencies]
+testing = [
+    "coverage[toml]",
+]
+
+[project.urls]
+"Homepage" = "https://github.com/cfpb/wagtail-inventory"
+"Bug Reports" = "https://github.com/cfpb/wagtail-inventory/issues"
+"Source" = "https://github.com/cfpb/wagtail-inventory"
+
+[build-system]
+requires = ["setuptools>=43.0.0", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[tool.setuptools.package-data]
+inventory = [
+    "templates/wagtailinventory/*",
+]
+
 [tool.black]
 line-length = 79
-target-version = ['py36', 'py38']
+target-version = ["py38"]
 include = '\.pyi?$'
 exclude = '''
 (
@@ -13,9 +59,6 @@ exclude = '''
     | build
     | dist
     | migrations
-    | site
-    | \*.json
-    | \*.csv
   )/
 )
 '''
@@ -37,5 +80,25 @@ sections = [
     "LOCALFOLDER"
 ]
 
-[build-system]
-requires = ["setuptools", "wheel"]
+[tool.ruff]
+exclude = [
+    ".git",
+    ".tox",
+    "__pycache__",
+    "*/migrations/*.py",
+    "*/tests/testapp/migrations/*.py",
+    "docs",
+    ".venv",
+    "venv",
+]
+ignore = []
+select = [
+    "E",
+    "F",
+    "W",
+]
+
+[tool.coverage.run]
+omit = [
+    "wagtailinventory/tests/*",
+]
diff --git a/setup.py b/setup.py
index 7d5fc37..b024da8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,42 +1,4 @@
-from setuptools import find_packages, setup
+from setuptools import setup
 
 
-install_requires = [
-    "tqdm>=4.15.0,<5",
-    "wagtail>=2.15,<4.2",
-]
-
-
-testing_extras = [
-    "coverage>=3.7.0",
-    "mock>=1.0.0",
-]
-
-setup(
-    name="wagtail-inventory",
-    url="https://github.com/cfpb/wagtail-inventory",
-    author="CFPB",
-    author_email="tech@cfpb.gov",
-    description="Lookup Wagtail pages by block content",
-    long_description=open("README.rst", "r", encoding="utf-8").read(),
-    license="CCO",
-    version="1.6",
-    include_package_data=True,
-    packages=find_packages(),
-    python_requires=">=3.8",
-    install_requires=install_requires,
-    extras_require={"testing": testing_extras},
-    classifiers=[
-        "Framework :: Django",
-        "Framework :: Django :: 3.2",
-        "Framework :: Django :: 4.0",
-        "Framework :: Wagtail",
-        "Framework :: Wagtail :: 2",
-        "Framework :: Wagtail :: 3",
-        "Framework :: Wagtail :: 4",
-        "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
-        "License :: Public Domain",
-        "Programming Language :: Python",
-        "Programming Language :: Python :: 3",
-    ],
-)
+setup()
diff --git a/tox.ini b/tox.ini
index 9368ee3..5daa42b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,42 +2,48 @@
 skipsdist=True
 envlist=
     lint,
-    python{3.8,3.10}-django{3.2}-wagtail{2.15,3.0,4.0,4.1}
-    python{3.8,3.10}-django{4.0}-wagtail{3.0,4.0,4.1}
-    python{3.8,3.10}-django{4.1}-wagtail{4.0,4.1}
+    python{3.8}-django{3.2}-wagtail{3.0},
+    python{3.8,3.11}-django{3.2,4.1}-wagtail{4.1,4.2},
+    coverage
 
 [testenv]
 install_command=pip install -e ".[testing]" -U {opts} {packages}
 commands=
-    coverage erase
-    coverage run {toxinidir}/testmanage.py test {posargs}
-    coverage report --show-missing --fail-under=100
+    python -b -m coverage run --parallel-mode --source='wagtailinventory' {toxinidir}/testmanage.py test {posargs}
 
 basepython=
     python3.8: python3.8
-    python3.10: python3.10
+    python3.11: python3.11
 
 deps=
-    mock>=1.0.0
     django3.2: Django>=3.2,<3.3
-    django4.0: Django>=4.0,<4.1
     django4.1: Django>=4.1,<4.2
-    wagtail2.15: wagtail>=2.15,<2.16
-    wagtail3.0: wagtail>=3.0,<3.1
-    wagtail4.0: wagtail>=4.0,<4.1
+    wagtail3.0: wagtail>=3.0,<4.0
     wagtail4.1: wagtail>=4.1,<4.2
+    wagtail4.2: wagtail>=4.2,<5.0
 
 [testenv:lint]
 basepython=python3.8
 deps=
     black
-    flake8
+    ruff
     isort
 commands=
     black --check wagtailinventory setup.py testmanage.py
-    flake8 wagtailinventory setup.py testmanage.py
+    ruff wagtailinventory testmanage.py
     isort --check-only --diff wagtailinventory testmanage.py
 
+[testenv:coverage]
+basepython=python3.8
+deps=
+    coverage[toml]
+    diff_cover
+commands=
+    coverage combine
+    coverage report -m
+    coverage xml
+    diff-cover coverage.xml --compare-branch=origin/main --fail-under=100
+
 [testenv:interactive]
 basepython=python3.8
 
@@ -53,15 +59,3 @@ commands=
 
 setenv=
     INTERACTIVE=1
-
-[isort]
-combine_as_imports=1
-lines_after_imports=2
-include_trailing_comma=1
-multi_line_output=3
-skip=.tox,migrations
-use_parentheses=1
-known_django=django
-known_wagtail=wagtail
-default_section=THIRDPARTY
-sections=FUTURE,STDLIB,DJANGO,WAGTAIL,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
diff --git a/wagtailinventory/forms.py b/wagtailinventory/forms.py
index 61c9b80..899871b 100644
--- a/wagtailinventory/forms.py
+++ b/wagtailinventory/forms.py
@@ -2,7 +2,7 @@
 from django.db.models.fields import BLANK_CHOICE_DASH
 from django.forms import formset_factory
 
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 from wagtailinventory.models import PageBlock
 
diff --git a/wagtailinventory/helpers.py b/wagtailinventory/helpers.py
index ecb06ff..cad87d3 100644
--- a/wagtailinventory/helpers.py
+++ b/wagtailinventory/helpers.py
@@ -1,7 +1,7 @@
 from itertools import chain
 
-from wagtail.core.blocks import ListBlock, StreamBlock, StructBlock
-from wagtail.core.fields import StreamField
+from wagtail.blocks import ListBlock, StreamBlock, StructBlock
+from wagtail.fields import StreamField
 
 from wagtailinventory.models import PageBlock
 
diff --git a/wagtailinventory/management/commands/block_inventory.py b/wagtailinventory/management/commands/block_inventory.py
index a7ce779..655e971 100644
--- a/wagtailinventory/management/commands/block_inventory.py
+++ b/wagtailinventory/management/commands/block_inventory.py
@@ -1,6 +1,6 @@
 from django.core.management import BaseCommand
 
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 from tqdm import tqdm
 
diff --git a/wagtailinventory/models.py b/wagtailinventory/models.py
index 2b0d758..0e526c4 100644
--- a/wagtailinventory/models.py
+++ b/wagtailinventory/models.py
@@ -1,6 +1,6 @@
 from django.db import models
 
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 
 class PageBlock(models.Model):
diff --git a/wagtailinventory/views.py b/wagtailinventory/views.py
index b9db965..dab6cd6 100644
--- a/wagtailinventory/views.py
+++ b/wagtailinventory/views.py
@@ -3,7 +3,7 @@
 from django.shortcuts import render
 from django.views.generic import View
 
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 from wagtailinventory.forms import PageBlockQueryFormSet
 
diff --git a/wagtailinventory/wagtail_hooks.py b/wagtailinventory/wagtail_hooks.py
index f5cc0bc..4d0edab 100644
--- a/wagtailinventory/wagtail_hooks.py
+++ b/wagtailinventory/wagtail_hooks.py
@@ -1,7 +1,7 @@
 from django.urls import include, re_path, reverse
 
+from wagtail import hooks
 from wagtail.admin.menu import MenuItem
-from wagtail.core import hooks
 
 from wagtailinventory import urls
 from wagtailinventory.helpers import (


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b125639..4fd945e 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -8,10 +8,10 @@ jobs:
     name: lint
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
 
       - name: Set up Python
-        uses: actions/setup-python@v2
+        uses: actions/setup-python@v4
         with:
           python-version: 3.8
 
@@ -31,46 +31,19 @@ jobs:
 
     strategy:
       matrix:
-        python: ['3.8', '3.10']
-        django: ['3.2']
-        wagtail: ['2.15','3.0','4.0','4.1']
+        python: ['3.8', '3.11']
+        django: ['3.2', '4.1']
+        wagtail: ['4.1', '4.2']
         include:
           - python: '3.8'
-            django: '4.0'
+            django: '3.2'
             wagtail: '3.0'
-          - python: '3.10'
-            django: '4.0'
-            wagtail: '3.0'
-          - python: '3.8'
-            django: '4.0'
-            wagtail: '4.0'
-          - python: '3.8'
-            django: '4.0'
-            wagtail: '4.1'
-          - python: '3.10'
-            django: '4.0'
-            wagtail: '4.0'
-          - python: '3.10'
-            django: '4.0'
-            wagtail: '4.1'
-          - python: '3.8'
-            django: '4.1'
-            wagtail: '4.0'
-          - python: '3.8'
-            django: '4.1'
-            wagtail: '4.1'
-          - python: '3.10'
-            django: '4.1'
-            wagtail: '4.0'
-          - python: '3.10'
-            django: '4.1'
-            wagtail: '4.1'
 
     steps:
-      - uses: actions/checkout@v2
+      - uses: actions/checkout@v3
 
       - name: Set up Python
-        uses: actions/setup-python@v2
+        uses: actions/setup-python@v4
         with:
           python-version: ${{ matrix.python }}
 
@@ -82,8 +55,39 @@ jobs:
       - name: Run tox
         run: |
             tox
-            coveralls
         env:
           TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          COVERALLS_SERVICE_NAME: github
+
+      - name: Store test coverage
+        uses: actions/upload-artifact@v2
+        with:
+          name: coverage
+          path: .coverage.*
+
+  coverage:
+    name: coverage
+    runs-on: ubuntu-latest
+    needs:
+      - test
+
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+
+      - name: Set up Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: "3.8"
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install tox
+      - name: Retrieve test coverage
+        uses: actions/download-artifact@v2
+        with:
+          name: coverage
+
+      - name: Check coverage
+        run: tox -e coverage
diff --git a/testmanage.py b/testmanage.py
index f101483..6a9cc09 100644
--- a/testmanage.py
+++ b/testmanage.py
@@ -56,7 +56,7 @@ def runtests():
     try:
         execute_from_command_line(argv)
     finally:
-        from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT
+        from wagtail.test.settings import MEDIA_ROOT, STATIC_ROOT
 
         shutil.rmtree(STATIC_ROOT, ignore_errors=True)
         shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
diff --git a/wagtailinventory/tests/settings.py b/wagtailinventory/tests/settings.py
index 28a8703..9bc264d 100644
--- a/wagtailinventory/tests/settings.py
+++ b/wagtailinventory/tests/settings.py
@@ -21,7 +21,7 @@
     "wagtail.contrib.forms",
     "wagtail.contrib.settings",
     "wagtail.admin",
-    "wagtail.core",
+    "wagtail",
     "wagtail.documents",
     "wagtail.images",
     "wagtail.sites",
@@ -30,7 +30,7 @@
 
 WAGTAILADMIN_RICH_TEXT_EDITORS = {
     "default": {"WIDGET": "wagtail.admin.rich_text.DraftailRichTextArea"},
-    "custom": {"WIDGET": "wagtail.tests.testapp.rich_text.CustomRichTextArea"},
+    "custom": {"WIDGET": "wagtail.test.testapp.rich_text.CustomRichTextArea"},
 }
 
 MIDDLEWARE = (
diff --git a/wagtailinventory/tests/test_forms.py b/wagtailinventory/tests/test_forms.py
index ba22cfa..20e7f82 100644
--- a/wagtailinventory/tests/test_forms.py
+++ b/wagtailinventory/tests/test_forms.py
@@ -1,7 +1,7 @@
 from django.db.models.fields import BLANK_CHOICE_DASH
 from django.test import TestCase
 
-from wagtail.core.models import Page, Site
+from wagtail.models import Page, Site
 
 from wagtailinventory.forms import PageBlockQueryForm, PageBlockQueryFormSet
 from wagtailinventory.models import PageBlock
diff --git a/wagtailinventory/tests/test_helpers.py b/wagtailinventory/tests/test_helpers.py
index e1e5a36..ee42068 100644
--- a/wagtailinventory/tests/test_helpers.py
+++ b/wagtailinventory/tests/test_helpers.py
@@ -1,8 +1,7 @@
 from django.core.management import call_command
 from django.test import TestCase
 
-import wagtail
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 from wagtailinventory.helpers import (
     get_page_blocks,
@@ -11,12 +10,6 @@
 )
 
 
-if wagtail.VERSION < (3, 0):  # pragma: nocover
-    CORE_BLOCKS = "wagtail.core.blocks"
-else:
-    CORE_BLOCKS = "wagtail.blocks"
-
-
 class TestGetPageBlocks(TestCase):
     fixtures = ["test_blocks.json"]
 
@@ -33,7 +26,7 @@ def test_streamfield_with_single_block(self):
         self.assertEqual(
             get_page_blocks(page),
             [
-                CORE_BLOCKS + ".field_block.CharBlock",
+                "wagtail.blocks.field_block.CharBlock",
                 "wagtailinventory.tests.testapp.blocks.Atom",
             ],
         )
@@ -43,8 +36,8 @@ def test_multiple_streamfields(self):
         self.assertEqual(
             get_page_blocks(page),
             [
-                CORE_BLOCKS + ".field_block.CharBlock",
-                CORE_BLOCKS + ".list_block.ListBlock",
+                "wagtail.blocks.field_block.CharBlock",
+                "wagtail.blocks.list_block.ListBlock",
                 "wagtailinventory.tests.testapp.blocks.Atom",
                 "wagtailinventory.tests.testapp.blocks.Molecule",
                 "wagtailinventory.tests.testapp.blocks.Organism",
@@ -56,8 +49,8 @@ def test_nested_streamblocks(self):
         self.assertEqual(
             get_page_blocks(page),
             [
-                CORE_BLOCKS + ".field_block.CharBlock",
-                CORE_BLOCKS + ".stream_block.StreamBlock",
+                "wagtail.blocks.field_block.CharBlock",
+                "wagtail.blocks.stream_block.StreamBlock",
                 "wagtailinventory.tests.testapp.blocks.Atom",
             ],
         )
diff --git a/wagtailinventory/tests/test_models.py b/wagtailinventory/tests/test_models.py
index 463412b..2fc4335 100644
--- a/wagtailinventory/tests/test_models.py
+++ b/wagtailinventory/tests/test_models.py
@@ -1,6 +1,6 @@
 from django.test import TestCase
 
-from wagtail.core.models import Page
+from wagtail.models import Page
 
 from wagtailinventory.models import PageBlock
 
diff --git a/wagtailinventory/tests/test_views.py b/wagtailinventory/tests/test_views.py
index 0882b2d..252f5f7 100644
--- a/wagtailinventory/tests/test_views.py
+++ b/wagtailinventory/tests/test_views.py
@@ -4,8 +4,8 @@
 from django.test import TestCase
 from django.urls import reverse
 
-from wagtail.core.models import Page
-from wagtail.tests.utils import WagtailTestUtils
+from wagtail.models import Page
+from wagtail.test.utils import WagtailTestUtils
 
 
 class SearchViewTests(WagtailTestUtils, TestCase):
diff --git a/wagtailinventory/tests/test_wagtail_hooks.py b/wagtailinventory/tests/test_wagtail_hooks.py
index 6d1a8da..112ec78 100644
--- a/wagtailinventory/tests/test_wagtail_hooks.py
+++ b/wagtailinventory/tests/test_wagtail_hooks.py
@@ -1,19 +1,12 @@
 from django.test import TestCase
 from django.urls import reverse
 
-import wagtail
-from wagtail.core.models import Page, Site
-from wagtail.tests.utils import WagtailTestUtils
+from wagtail.models import Page, Site
+from wagtail.test.utils import WagtailTestUtils
 
 from wagtailinventory.models import PageBlock
 
 
-if wagtail.VERSION < (3, 0):  # pragma: nocover
-    CORE_BLOCKS = "wagtail.core.blocks"
-else:
-    CORE_BLOCKS = "wagtail.blocks"
-
-
 class TestWagtailHooks(TestCase, WagtailTestUtils):
     def setUp(self):
         self.root_page = Site.objects.get(is_default_site=True).root_page
@@ -61,8 +54,8 @@ def test_inventory_hooks(self):
                 )
             ),
             [
-                CORE_BLOCKS + ".field_block.CharBlock",
-                CORE_BLOCKS + ".list_block.ListBlock",
+                "wagtail.blocks.field_block.CharBlock",
+                "wagtail.blocks.list_block.ListBlock",
                 "wagtailinventory.tests.testapp.blocks.Atom",
                 "wagtailinventory.tests.testapp.blocks.Molecule",
             ],
@@ -97,7 +90,7 @@ def test_inventory_hooks(self):
                 )
             ),
             [
-                CORE_BLOCKS + ".field_block.CharBlock",
+                "wagtail.blocks.field_block.CharBlock",
                 "wagtailinventory.tests.testapp.blocks.Atom",
             ],
         )
diff --git a/wagtailinventory/tests/testapp/blocks.py b/wagtailinventory/tests/testapp/blocks.py
index bb0d7df..993dbc1 100644
--- a/wagtailinventory/tests/testapp/blocks.py
+++ b/wagtailinventory/tests/testapp/blocks.py
@@ -1,4 +1,4 @@
-from wagtail.core import blocks
+from wagtail import blocks
 
 
 class Atom(blocks.StructBlock):
diff --git a/wagtailinventory/tests/testapp/migrations/0001_initial.py b/wagtailinventory/tests/testapp/migrations/0001_initial.py
index a2afff7..47417d8 100644
--- a/wagtailinventory/tests/testapp/migrations/0001_initial.py
+++ b/wagtailinventory/tests/testapp/migrations/0001_initial.py
@@ -1,9 +1,9 @@
 # -*- coding: utf-8 -*-
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
-from wagtail.core import blocks as core_blocks
-from wagtail.core import fields as core_fields  # pragma: no cover
+from wagtail import blocks as core_blocks
+from wagtail import fields as core_fields
 
 
 class Migration(migrations.Migration):
@@ -19,8 +19,8 @@ class Migration(migrations.Migration):
             name='MultipleStreamFieldsPage',
             fields=[
                 ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
-                ('first', core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))])),
-                ('second', core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))])),
+                ('first', core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))], use_json_field=True)),
+                ('second', core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))], use_json_field=True)),
             ],
             options={
                 'abstract': False,
@@ -42,7 +42,7 @@ class Migration(migrations.Migration):
             name='SingleStreamFieldPage',
             fields=[
                 ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
-                ('content', core_fields.StreamField([('text', core_blocks.CharBlock()), ('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))])),
+                ('content', core_fields.StreamField([('text', core_blocks.CharBlock()), ('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))], use_json_field=True)),
             ],
             options={
                 'abstract': False,
diff --git a/wagtailinventory/tests/testapp/migrations/0002_nested_stream_block_page.py b/wagtailinventory/tests/testapp/migrations/0002_nested_stream_block_page.py
index a9b68f1..70b91a7 100644
--- a/wagtailinventory/tests/testapp/migrations/0002_nested_stream_block_page.py
+++ b/wagtailinventory/tests/testapp/migrations/0002_nested_stream_block_page.py
@@ -1,9 +1,9 @@
 # -*- coding: utf-8 -*-
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
-from wagtail.core import blocks as core_blocks
-from wagtail.core import fields as core_fields  # pragma: no cover
+from wagtail import blocks as core_blocks
+from wagtail import fields as core_fields
 
 
 class Migration(migrations.Migration):
@@ -17,7 +17,7 @@ class Migration(migrations.Migration):
             name='NestedStreamBlockPage',
             fields=[
                 ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
-                ('content', core_fields.StreamField([('streamblock', core_blocks.StreamBlock([('text', core_blocks.CharBlock()), ('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())]))]))])),
+                ('content', core_fields.StreamField([('streamblock', core_blocks.StreamBlock([('text', core_blocks.CharBlock()), ('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())]))]))], use_json_field=True)),
             ],
             options={
                 'abstract': False,
diff --git a/wagtailinventory/tests/testapp/migrations/0003_single_content_block_optional.py b/wagtailinventory/tests/testapp/migrations/0003_single_content_block_optional.py
index 8631885..f2d0038 100644
--- a/wagtailinventory/tests/testapp/migrations/0003_single_content_block_optional.py
+++ b/wagtailinventory/tests/testapp/migrations/0003_single_content_block_optional.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 from django.db import migrations
 
-from wagtail.core import blocks as core_blocks
-from wagtail.core import fields as core_fields  # pragma: no cover
+from wagtail import blocks as core_blocks
+from wagtail import fields as core_fields
 
 
 class Migration(migrations.Migration):
@@ -15,6 +15,6 @@ class Migration(migrations.Migration):
         migrations.AlterField(
             model_name='singlestreamfieldpage',
             name='content',
-            field=core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))], blank=True),
+            field=core_fields.StreamField([('atom', core_blocks.StructBlock([('title', core_blocks.CharBlock())])), ('molecule', core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])), ('organism', core_blocks.StructBlock([('molecules', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock()), ('atoms', core_blocks.ListBlock(core_blocks.StructBlock([('title', core_blocks.CharBlock())])))])))]))], blank=True, use_json_field=True),
         ),
     ]
diff --git a/wagtailinventory/tests/testapp/models.py b/wagtailinventory/tests/testapp/models.py
index 39ee300..f7767fd 100644
--- a/wagtailinventory/tests/testapp/models.py
+++ b/wagtailinventory/tests/testapp/models.py
@@ -1,9 +1,9 @@
 from django.db import models
 
-from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
-from wagtail.core import blocks as wagtail_blocks
-from wagtail.core.fields import StreamField
-from wagtail.core.models import Page
+from wagtail import blocks as wagtail_blocks
+from wagtail.admin.panels import FieldPanel
+from wagtail.fields import StreamField
+from wagtail.models import Page
 
 from wagtailinventory.tests.testapp import blocks
 
@@ -24,10 +24,11 @@ class SingleStreamFieldPage(Page):
             ("organism", blocks.Organism()),
         ],
         blank=True,
+        use_json_field=True,
     )
 
     content_panels = Page.content_panels + [
-        StreamFieldPanel("content"),
+        FieldPanel("content"),
     ]
 
 
@@ -38,6 +39,7 @@ class MultipleStreamFieldsPage(Page):
             ("molecule", blocks.Molecule()),
             ("organism", blocks.Organism()),
         ],
+        use_json_field=True,
     )
     second = StreamField(
         [
@@ -45,11 +47,12 @@ class MultipleStreamFieldsPage(Page):
             ("molecule", blocks.Molecule()),
             ("organism", blocks.Organism()),
         ],
+        use_json_field=True,
     )
 
     content_panels = Page.content_panels + [
-        StreamFieldPanel("first"),
-        StreamFieldPanel("second"),
+        FieldPanel("first"),
+        FieldPanel("second"),
     ]
 
 
@@ -66,8 +69,9 @@ class NestedStreamBlockPage(Page):
                 ),
             ),
         ],
+        use_json_field=True,
     )
 
     content_panels = Page.content_panels + [
-        StreamFieldPanel("content"),
+        FieldPanel("content"),
     ]
diff --git a/wagtailinventory/tests/urls.py b/wagtailinventory/tests/urls.py
index 7baa696..4d02142 100644
--- a/wagtailinventory/tests/urls.py
+++ b/wagtailinventory/tests/urls.py
@@ -1,7 +1,7 @@
 from django.conf import settings
 
+from wagtail import urls as wagtailcore_urls
 from wagtail.admin import urls as wagtailadmin_urls
-from wagtail.core import urls as wagtailcore_urls
 from wagtail.documents import urls as wagtaildocs_urls