diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9439680..9a05fe3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,9 @@ jobs: builddist: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 873e065..f6b8c84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.x - name: Windows Venv @@ -58,9 +58,9 @@ jobs: matrix: python-version: [ "pypy-3.10", "3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install @@ -89,9 +89,9 @@ jobs: needs: versions runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Install phmutest @@ -107,12 +107,9 @@ jobs: isort - - name: Formatting # Show reformatting changes. - # Make the changes. - # Subsequent steps run with the modified files. # Don't run black on the generated test files. run: | - black **/*.py --check --force-exclude="tests/py" - black **/*.py --force-exclude="tests/py" + black **/*.py --diff --force-exclude="tests/py" continue-on-error: true - name: Code Style run: | @@ -130,7 +127,7 @@ jobs: python docs/premkdocs.py mkdocs build - name: Upload mkdocs site - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: site path: site @@ -141,10 +138,10 @@ jobs: needs: inspect runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x id: setuppython - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.x - name: Install phmutest @@ -167,7 +164,7 @@ jobs: continue-on-error: true - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml # optional diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 11c4f96..80b63ca 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,10 +14,10 @@ jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x id: setuppython - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.x - name: Install phmutest @@ -40,7 +40,7 @@ jobs: continue-on-error: true - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml # optional diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7398923..5030336 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,17 +6,17 @@ on: workflow_dispatch: env: - ref: v0.0.3 + ref: v0.0.4 jobs: builddist: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ env.ref }} - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.x @@ -27,7 +27,7 @@ jobs: python -m pip hash dist/* - name: Upload dist - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dist-${{ env.ref }} path: dist/* diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index a9d0df3..b5bee84 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -5,14 +5,14 @@ on: env: project: phmutest - version: 0.0.3 + version: 0.0.4 command: phmutest jobs: pypi-install: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.10" diff --git a/LICENSE b/LICENSE index 917f8a8..1d862c7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Mark Taylor +Copyright (c) 2024 Mark Taylor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ba819b0..dba8787 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# phmutest 0.0.3 +# phmutest 0.0.4 ## Detect broken Python examples in Markdown diff --git a/docs/api.md b/docs/api.md index b5b78e5..eaebf9e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,4 +1,4 @@ -# Tool API for phmutest version 0.0.3 +# Tool API for phmutest version 0.0.4 ## API - phmutest.tool diff --git a/docs/fixture_py.md b/docs/fixture_py.md index 0092004..fa18bf9 100644 --- a/docs/fixture_py.md +++ b/docs/fixture_py.md @@ -1,7 +1,7 @@ # src/phmutest/fixture.py ```python -"""v0.0.3 Keyword arguments passed to --fixture function and return type Fixture. +"""v0.0.4 Keyword arguments passed to --fixture function and return type Fixture. These are passed to the fixture function as keyword arguments: @@ -21,6 +21,7 @@ is_replmode Python bool. True when commandline argument --replmode is present. """ + from dataclasses import dataclass from typing import Callable, MutableMapping, Optional diff --git a/docs/generated_project_py.md b/docs/generated_project_py.md index 012d988..514299e 100644 --- a/docs/generated_project_py.md +++ b/docs/generated_project_py.md @@ -10,6 +10,7 @@ from phmutest.skip import sys_tool as _phm_sys _phm_globals = None _phm_testcase = unittest.TestCase() +_phm_testcase.maxDiff = None _phm_log = [] diff --git a/docs/generated_share_demo_py.md b/docs/generated_share_demo_py.md index 61c759d..86ab165 100644 --- a/docs/generated_share_demo_py.md +++ b/docs/generated_share_demo_py.md @@ -10,6 +10,7 @@ from phmutest.skip import sys_tool as _phm_sys _phm_globals = None _phm_testcase = unittest.TestCase() +_phm_testcase.maxDiff = None _phm_log = [] diff --git a/docs/make_wrapped_examples.py b/docs/make_wrapped_examples.py index 1793e6d..e58e842 100644 --- a/docs/make_wrapped_examples.py +++ b/docs/make_wrapped_examples.py @@ -1,4 +1,5 @@ """Create Markdown wrappers around the project's example .py files.""" + from pathlib import Path top = "# \n\n```python\n" diff --git a/docs/premkdocs.py b/docs/premkdocs.py index 4fc9e65..833f198 100644 --- a/docs/premkdocs.py +++ b/docs/premkdocs.py @@ -6,6 +6,7 @@ - enter Ctrl-C to discontinue watching and shut down the mkdocs server Suggest adding the mkdocs.yml docs_dir to .gitignore. """ + import subprocess import sys from multiprocessing import Process diff --git a/docs/recent_changes.md b/docs/recent_changes.md index 53f39dd..7be0f7d 100644 --- a/docs/recent_changes.md +++ b/docs/recent_changes.md @@ -22,3 +22,9 @@ 0.0.3 - 2023-09-24 - Add test_importer.py. Cleanups + +0.0.4 - 2024-09-05 + +- Bugfix- Issue- The generated expected output check in code mode + asserts if the FCB length is greater than a fairly small value. +- Python source formatting updates per Black 24.3.0. diff --git a/mkdocs.yml b/mkdocs.yml index 3423ad9..3173c65 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,6 @@ -site_name: phmutest 0.0.3 +site_name: phmutest 0.0.4 site_description: Detect broken Python examples in Markdown -copyright: Copyright (c) 2023 Mark Taylor +copyright: Copyright (c) 2024 Mark Taylor docs_dir: _mkdocsin theme: readthedocs nav: diff --git a/setup.cfg b/setup.cfg index 4d8e1c0..2a73056 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ license_files = LICENSE # https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html name = phmutest -version = 0.0.3 +version = 0.0.4 author = Mark Taylor author_email = mark66547ta2@gmail.com description = Detect broken Python examples in Markdown. diff --git a/src/phmutest/__init__.py b/src/phmutest/__init__.py index 27fdca4..81f0fde 100644 --- a/src/phmutest/__init__.py +++ b/src/phmutest/__init__.py @@ -1 +1 @@ -__version__ = "0.0.3" +__version__ = "0.0.4" diff --git a/src/phmutest/cases.py b/src/phmutest/cases.py index 2a2b6d3..572bc0b 100644 --- a/src/phmutest/cases.py +++ b/src/phmutest/cases.py @@ -1,4 +1,5 @@ """Generate test cases as a unittest test file.""" + import argparse from pathlib import Path @@ -75,12 +76,12 @@ def render_setup_module( replacements["shareid"] = shareid replacements["setupblocks"] = deindented_setup_blocks if args.progress: - replacements[ - "showprogressenter" - ] = '_phm_sys.stderr_printer("setUpModule()...")' - replacements[ - "showprogressexit" - ] = '_phm_sys.stderr_printer("leaving setUpModule.")' + replacements["showprogressenter"] = ( + '_phm_sys.stderr_printer("setUpModule()...")' + ) + replacements["showprogressexit"] = ( + '_phm_sys.stderr_printer("leaving setUpModule.")' + ) if args.fixture: replacements["userfixtureglobs"] = phmutest.subtest.justify( @@ -128,12 +129,12 @@ def render_teardown_module( replacements["teardownblocks"] = deindented_teardown_blocks if args.progress: - replacements[ - "showprogressenter" - ] = '_phm_sys.stderr_printer("tearDownModule()...")' - replacements[ - "showprogressexit" - ] = '_phm_sys.stderr_printer("leaving tearDownModule.")' + replacements["showprogressenter"] = ( + '_phm_sys.stderr_printer("tearDownModule()...")' + ) + replacements["showprogressexit"] = ( + '_phm_sys.stderr_printer("leaving tearDownModule.")' + ) return phmutest.subtest.fill_in( teardown_module_form, @@ -319,6 +320,7 @@ def markdown_file( $callfixture _phm_globals = None _phm_testcase = unittest.TestCase() +_phm_testcase.maxDiff = None _phm_log = [] $setupmodule $teardownmodule diff --git a/src/phmutest/code.py b/src/phmutest/code.py index af50bd7..10c6bc1 100644 --- a/src/phmutest/code.py +++ b/src/phmutest/code.py @@ -1,4 +1,5 @@ """Run the generated unittest source file with unittest.main.""" + import argparse import copy import importlib diff --git a/src/phmutest/config.py b/src/phmutest/config.py index f131a50..c369910 100644 --- a/src/phmutest/config.py +++ b/src/phmutest/config.py @@ -16,6 +16,7 @@ --generate, --progress, --sharing, --log, --summary, --report """ + import argparse from pathlib import Path from typing import List diff --git a/src/phmutest/direct.py b/src/phmutest/direct.py index 2e22e37..396eb73 100644 --- a/src/phmutest/direct.py +++ b/src/phmutest/direct.py @@ -1,4 +1,5 @@ """Find phmutest Directives in HTML comment Nodes.""" + import re from dataclasses import dataclass from enum import Enum, auto diff --git a/src/phmutest/fixture.py b/src/phmutest/fixture.py index 9cbd055..d0e7c61 100644 --- a/src/phmutest/fixture.py +++ b/src/phmutest/fixture.py @@ -1,4 +1,4 @@ -"""v0.0.3 Keyword arguments passed to --fixture function and return type Fixture. +"""v0.0.4 Keyword arguments passed to --fixture function and return type Fixture. These are passed to the fixture function as keyword arguments: @@ -18,6 +18,7 @@ Python bool. True when commandline argument --replmode is present. """ + from dataclasses import dataclass from typing import Callable, MutableMapping, Optional diff --git a/src/phmutest/globs.py b/src/phmutest/globs.py index dbaa34d..fbe9f24 100644 --- a/src/phmutest/globs.py +++ b/src/phmutest/globs.py @@ -1,4 +1,5 @@ """Imported by the generated test file to manage test module globals.""" + import inspect import sys import types diff --git a/src/phmutest/importer.py b/src/phmutest/importer.py index 3c2c21c..5f34b18 100644 --- a/src/phmutest/importer.py +++ b/src/phmutest/importer.py @@ -1,4 +1,5 @@ """Import user's fixture function given the relative dotted path.""" + import importlib.util import sys from pathlib import Path diff --git a/src/phmutest/main.py b/src/phmutest/main.py index 0935f0f..03a1e34 100644 --- a/src/phmutest/main.py +++ b/src/phmutest/main.py @@ -1,4 +1,5 @@ """Command line parsing, main entry point, and top level operations.""" + import argparse import pathlib import sys diff --git a/src/phmutest/printer.py b/src/phmutest/printer.py index 36d8eb2..f7cb4c0 100644 --- a/src/phmutest/printer.py +++ b/src/phmutest/printer.py @@ -1,4 +1,5 @@ """Context manager to print and log entry and exit status of a code block run.""" + import contextlib import io import sys diff --git a/src/phmutest/select.py b/src/phmutest/select.py index acb8af8..abc9183 100644 --- a/src/phmutest/select.py +++ b/src/phmutest/select.py @@ -1,4 +1,5 @@ """Identify/select/deselect FCBs per info string, test groups and directives.""" + import argparse from dataclasses import dataclass from pathlib import Path diff --git a/src/phmutest/session.py b/src/phmutest/session.py index cd03ef0..25daaf7 100644 --- a/src/phmutest/session.py +++ b/src/phmutest/session.py @@ -1,4 +1,5 @@ """Generate and run docstests for Python interactive session FCBs.""" + import argparse import doctest import itertools diff --git a/src/phmutest/skip.py b/src/phmutest/skip.py index 76f42e1..aad1471 100644 --- a/src/phmutest/skip.py +++ b/src/phmutest/skip.py @@ -1,4 +1,5 @@ """Process skip directives. Encapsulate access to Python standard library sys.""" + import argparse import sys from dataclasses import dataclass @@ -69,9 +70,9 @@ def make_replacements( """Create mapping for Template string replacement.""" replacements = dict(line=doc_location, log_reason=log_reason) if verbose: - replacements[ - "print" - ] = f'_phm_sys.stderr_printer("{doc_location} ... skip {log_reason}")' + replacements["print"] = ( + f'_phm_sys.stderr_printer("{doc_location} ... skip {log_reason}")' + ) return replacements diff --git a/src/phmutest/subtest.py b/src/phmutest/subtest.py index 25ae652..2fbda09 100644 --- a/src/phmutest/subtest.py +++ b/src/phmutest/subtest.py @@ -1,4 +1,5 @@ """Generate code to test Python FCBs.""" + import argparse import re import textwrap diff --git a/src/phmutest/summary.py b/src/phmutest/summary.py index 0c07540..46c5b17 100644 --- a/src/phmutest/summary.py +++ b/src/phmutest/summary.py @@ -1,4 +1,5 @@ """Define main() result type. Print test results.""" + import argparse import unittest from collections import Counter diff --git a/src/phmutest/tool.py b/src/phmutest/tool.py index b23e8a5..9766540 100644 --- a/src/phmutest/tool.py +++ b/src/phmutest/tool.py @@ -1,4 +1,5 @@ """General purpose tools get fenced code blocks from Markdown.""" + from dataclasses import dataclass from operator import attrgetter from pathlib import Path diff --git a/tests/check_classifiers.py b/tests/check_classifiers.py index 9a8541c..cf07277 100644 --- a/tests/check_classifiers.py +++ b/tests/check_classifiers.py @@ -10,6 +10,7 @@ https://pypi.org/classifiers/ """ + import configparser import sys diff --git a/tests/conftest.py b/tests/conftest.py index e523864..cb7b80b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ """Fixtures used in multiple test files. Checkers are helpful with pytest 6.2.5.""" + import inspect import unittest diff --git a/tests/py/generated_project.py b/tests/py/generated_project.py index 106060a..d13c277 100644 --- a/tests/py/generated_project.py +++ b/tests/py/generated_project.py @@ -7,6 +7,7 @@ _phm_globals = None _phm_testcase = unittest.TestCase() +_phm_testcase.maxDiff = None _phm_log = [] diff --git a/tests/py/generated_sharedemo.py b/tests/py/generated_sharedemo.py index 92e1480..665ab5e 100644 --- a/tests/py/generated_sharedemo.py +++ b/tests/py/generated_sharedemo.py @@ -7,6 +7,7 @@ _phm_globals = None _phm_testcase = unittest.TestCase() +_phm_testcase.maxDiff = None _phm_log = [] diff --git a/tests/test_api.py b/tests/test_api.py index 2b80357..f92b983 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,4 +1,5 @@ """Check the hand copying from tool.py into api.md.""" + from pathlib import Path import phmutest.tool @@ -25,4 +26,4 @@ def test_api(): # wc src/phmutest/tool.py exp_code_length = len(codetext) msg = f"tool.py length has changed to {exp_code_length}, is api.md up to date?" - assert exp_code_length == 5339, msg + assert exp_code_length == 5340, msg diff --git a/tests/test_cases.py b/tests/test_cases.py index 2e2cfa3..9432be5 100644 --- a/tests/test_cases.py +++ b/tests/test_cases.py @@ -1,4 +1,5 @@ """Tests for cases.py and other source files to provide code coverage.""" + import contextlib import io import textwrap diff --git a/tests/test_direct.py b/tests/test_direct.py index 09b9051..436973b 100644 --- a/tests/test_direct.py +++ b/tests/test_direct.py @@ -1,4 +1,5 @@ """Test HTML comment directives implemented in direct.py and fenced.py.""" + from pathlib import Path import phmutest.select diff --git a/tests/test_dist.py b/tests/test_dist.py index c577b2f..b7d772a 100644 --- a/tests/test_dist.py +++ b/tests/test_dist.py @@ -1,4 +1,5 @@ """Test project packaging.""" + import configparser import subprocess from pathlib import Path @@ -65,7 +66,7 @@ def test_wheel_yml(self): def test_consistent_copyright(): """Assure same copyright phrasing in the various source locations.""" - year = 2023 + year = 2024 assert f"Copyright (c) {year}" in Path("LICENSE").read_text(encoding="utf-8") assert f"Copyright (c) {year}" in Path("mkdocs.yml").read_text(encoding="utf-8") diff --git a/tests/test_docs.py b/tests/test_docs.py index f57bb34..02120eb 100644 --- a/tests/test_docs.py +++ b/tests/test_docs.py @@ -1,4 +1,5 @@ """pytest tests for README.md and other Markdown doc files.""" + import contextlib import re import textwrap diff --git a/tests/test_errors.py b/tests/test_errors.py index 13a831b..f14802c 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,4 +1,5 @@ """Check handling of user code raising an exception. Python code, REPLs, --fixture.""" + import contextlib import io diff --git a/tests/test_examples.py b/tests/test_examples.py index 5f14e1c..f30983f 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,4 +1,5 @@ """Test runs calling phmutest.main.main() from Python with command line arguments.""" + import phmutest.main import phmutest.summary diff --git a/tests/test_extra_args.py b/tests/test_extra_args.py index e42c222..cdc3030 100644 --- a/tests/test_extra_args.py +++ b/tests/test_extra_args.py @@ -1,4 +1,5 @@ """Check pass through of extra args to unittest.""" + import pytest import phmutest.main diff --git a/tests/test_fenced.py b/tests/test_fenced.py index ce0979e..28f25f6 100644 --- a/tests/test_fenced.py +++ b/tests/test_fenced.py @@ -1,4 +1,5 @@ """Test Python info string matching, command line skip, and --report.""" + import phmutest.main import phmutest.summary diff --git a/tests/test_generate.py b/tests/test_generate.py index c045a06..20e0a93 100644 --- a/tests/test_generate.py +++ b/tests/test_generate.py @@ -1,4 +1,5 @@ """Check handling of --generate command line option.""" + import os import unittest import unittest.main diff --git a/tests/test_globs.py b/tests/test_globs.py index 70ce93c..907afba 100644 --- a/tests/test_globs.py +++ b/tests/test_globs.py @@ -1,4 +1,5 @@ """Test Globals class from globs.py.""" + import copy import doctest import sys diff --git a/tests/test_patching.py b/tests/test_patching.py index 6044b44..f48e7e5 100644 --- a/tests/test_patching.py +++ b/tests/test_patching.py @@ -1,4 +1,5 @@ """Show use cases for patch points.""" + import copy import doctest from contextlib import ExitStack diff --git a/tests/test_reader.py b/tests/test_reader.py index 1d3d74d..8d6d130 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -1,4 +1,5 @@ """Test reading Markdown - reader.py.""" + from pathlib import Path import phmutest.reader diff --git a/tests/test_rebind.py b/tests/test_rebind.py index e384e55..d3b0813 100644 --- a/tests/test_rebind.py +++ b/tests/test_rebind.py @@ -30,6 +30,7 @@ To see the effect of rebind in REPL mode see test_globs.py::test_extractor(). """ + import unittest import phmutest.main diff --git a/tests/test_select.py b/tests/test_select.py index 7633b5d..6e88646 100644 --- a/tests/test_select.py +++ b/tests/test_select.py @@ -1,4 +1,5 @@ """Test test group select/deselect.""" + from pathlib import Path import phmutest.main diff --git a/tests/test_session.py b/tests/test_session.py index b17e694..2648957 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -1,4 +1,5 @@ """Test cases for session.py.""" + from unittest import mock import pytest diff --git a/tests/test_sharing.py b/tests/test_sharing.py index 692c655..d01509b 100644 --- a/tests/test_sharing.py +++ b/tests/test_sharing.py @@ -1,4 +1,5 @@ """Tests --sharing printing.""" + import contextlib import io import unittest diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index eda84df..d9e8b53 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -1,4 +1,5 @@ """Test subprocess call.""" + import subprocess import sys diff --git a/tests/test_tool.py b/tests/test_tool.py index 9ed229d..1702dcd 100644 --- a/tests/test_tool.py +++ b/tests/test_tool.py @@ -1,4 +1,5 @@ """Test tool.py""" + import phmutest.tool diff --git a/tests/test_wrapped_python_files.py b/tests/test_wrapped_python_files.py index 5e7ec10..352a000 100644 --- a/tests/test_wrapped_python_files.py +++ b/tests/test_wrapped_python_files.py @@ -1,4 +1,5 @@ """Check example Python file is the same as in Markdown fenced code block.""" + from pathlib import Path import phmutest.tool