From 3be40d808b263317cb7a7f5670761674d069b0d4 Mon Sep 17 00:00:00 2001 From: Jens Vagelpohl Date: Mon, 26 Aug 2024 14:38:54 +0200 Subject: [PATCH] - Run the latest meta/config template --- .github/workflows/pre-commit.yml | 33 +++ .github/workflows/tests.yml | 77 +------ .meta.toml | 2 +- .pre-commit-config.yaml | 28 +++ MANIFEST.in | 1 + docs/Makefile | 136 ++---------- docs/conf.py | 267 ++--------------------- setup.py | 7 +- src/persistent/persistence.py | 12 +- src/persistent/picklecache.py | 2 +- src/persistent/tests/cucumbers.py | 2 +- src/persistent/tests/test_list.py | 22 +- src/persistent/tests/test_mapping.py | 20 +- src/persistent/tests/test_persistence.py | 30 +-- src/persistent/tests/test_picklecache.py | 40 ++-- src/persistent/tests/test_ring.py | 6 +- src/persistent/tests/test_timestamp.py | 30 +-- src/persistent/tests/test_wref.py | 40 ++-- tox.ini | 17 +- 19 files changed, 209 insertions(+), 563 deletions(-) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..325ae0e --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,33 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +name: pre-commit + +on: + pull_request: + push: + branches: + - master + # Allow to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + FORCE_COLOR: 1 + +jobs: + pre-commit: + name: linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --show-diff-on-failure + env: + PRE_COMMIT_COLOR: always + - uses: pre-commit-ci/lite-action@v1.0.2 + if: always() + with: + msg: Apply pre-commit code formatting diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e29370e..4ef58ac 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ # Original comment follows. ### ### -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# This workflow will install Python dependencies, run tests with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions ### @@ -81,7 +81,7 @@ jobs: # other people to test/debug), the strategy is to divide the process # into several different jobs. The first builds and saves the binary # wheels. It has dependent jobs that download and install the wheel - # to run tests, build docs, and perform linting. Building the + # to run tests, and build docs. Building the # manylinux wheels is an independent set of jobs. # # This division is time-saving for projects that take awhile to @@ -387,7 +387,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9"] + python-version: ["3.11"] os: [ubuntu-latest] steps: @@ -451,80 +451,13 @@ jobs: sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest - lint: - needs: build-package - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ["3.9"] - os: [ubuntu-latest] - - steps: - - name: checkout - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - allow-prereleases: true - ### - # Caching. - # This actually *restores* a cache and schedules a cleanup action - # to save the cache. So it must come before the thing we want to use - # the cache. - ### - - name: Get pip cache dir (default) - id: pip-cache-default - if: ${{ !startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT - - - name: Get pip cache dir (Windows) - id: pip-cache-windows - if: ${{ startsWith(runner.os, 'Windows') }} - run: | - echo "dir=$(pip cache dir)" >> $Env:GITHUB_OUTPUT - - - name: pip cache (default) - uses: actions/cache@v4 - if: ${{ !startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-default.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: pip cache (Windows) - uses: actions/cache@v4 - if: ${{ startsWith(runner.os, 'Windows') }} - with: - path: ${{ steps.pip-cache-windows.outputs.dir }} - key: ${{ runner.os }}-pip-${{ matrix.python-version }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Download persistent wheel - uses: actions/download-artifact@v4 - with: - name: persistent-${{ runner.os }}-${{ matrix.python-version }}.whl - path: dist/ - - name: Install persistent - run: | - pip install -U pip - pip install -U wheel - pip install -U `ls dist/persistent-*`[test] - - name: Lint - run: | - pip install -U tox - tox -e lint - manylinux: runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name # We use a regular Python matrix entry to share as much code as possible. strategy: matrix: - python-version: ["3.9"] + python-version: ["3.11"] image: [manylinux2014_x86_64, manylinux2014_i686, manylinux2014_aarch64] steps: @@ -605,6 +538,8 @@ jobs: name: manylinux_${{ matrix.image }}_wheels.zip - name: Restore pip cache permissions run: sudo chown -R $(whoami) ${{ steps.pip-cache-default.outputs.dir }} + - name: Prevent publishing wheels for unreleased Python versions + run: VER=$(echo '3.13' | tr -d .) && ls -al wheelhouse && sudo rm -f wheelhouse/*-cp${VER}*.whl && ls -al wheelhouse - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 if: > diff --git a/.meta.toml b/.meta.toml index 15a5d20..41945be 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,7 +2,7 @@ # https://github.com/zopefoundation/meta/tree/master/config/c-code [meta] template = "c-code" -commit-id = "73f176ee" +commit-id = "9e2b2911" [python] with-appveyor = false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5d6386 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/c-code +minimum_pre_commit_version: '3.6' +repos: + - repo: https://github.com/pycqa/isort + rev: "5.13.2" + hooks: + - id: isort + - repo: https://github.com/hhatto/autopep8 + rev: "v2.3.1" + hooks: + - id: autopep8 + args: [--in-place, --aggressive, --aggressive] + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + - repo: https://github.com/isidentical/teyit + rev: 0.4.3 + hooks: + - id: teyit + - repo: https://github.com/PyCQA/flake8 + rev: "7.1.1" + hooks: + - id: flake8 + additional_dependencies: + - flake8-debugger == 4.1.2 diff --git a/MANIFEST.in b/MANIFEST.in index e6615af..da27953 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,7 @@ include *.rst include *.txt include buildout.cfg include tox.ini +include .pre-commit-config.yaml include .coveragerc recursive-include docs *.py diff --git a/docs/Makefile b/docs/Makefile index 1420ee8..d4bb2cb 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,130 +1,20 @@ -# Makefile for Sphinx documentation +# Minimal makefile for Sphinx documentation # -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . BUILDDIR = _build -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest - +# Put it first so that "make" without argument is like "make help". help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/persistent.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/persistent.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/persistent" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/persistent" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - make -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." +.PHONY: help Makefile -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py index 5341732..32ebcdb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,269 +1,34 @@ -# -*- coding: utf-8 -*- +# Configuration file for the Sphinx documentation builder. # -# persistent documentation build configuration file, created by -# sphinx-quickstart on Wed Feb 16 20:50:32 2011. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html -import sys, os +import datetime -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) -# -- General configuration ----------------------------------------------------- +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +year = datetime.datetime.now().year -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +project = 'persistent' +copyright = f'2011-{year}, Zope Foundation and contributors' +author = 'Zope Foundation and contributors' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.ifconfig', - 'sphinx.ext.viewcode', 'repoze.sphinx.autointerface', ] -# Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] +exclude_patterns = [] -# The suffix of source filenames. -source_suffix = {'.rst': 'restructuredtext'} - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'persistent' -copyright = u'2011,2016 ZODB Developers ' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '4.2' -# The full version, including alpha/beta/rc tags. -release = '4.2.2' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. html_theme = 'sphinx_rtd_theme' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'persistentdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'persistent.tex', u'persistent Documentation', - u'ZODB Developers \\textless{}zope-dev@zope.org\\textgreater{}', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'persistent', u'persistent Documentation', - [u'ZODB Developers '], 1) -] - - -# -- Options for Epub output --------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = u'persistent' -epub_author = u'ZODB Developers ' -epub_publisher = u'ZODB Developers ' -epub_copyright = u'2011, ZODB Developers ' - -# The language of the text. It defaults to the language option -# or en if the language is not set. -#epub_language = '' - -# The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' - -# The unique identifier of the text. This can be a ISBN number -# or the project homepage. -#epub_identifier = '' - -# A unique identification for the text. -#epub_uid = '' - -# HTML files that should be inserted before the pages created by sphinx. -# The format is a list of tuples containing the path and title. -#epub_pre_files = [] - -# HTML files shat should be inserted after the pages created by sphinx. -# The format is a list of tuples containing the path and title. -#epub_post_files = [] - -# A list of files that should not be packed into the epub file. -#epub_exclude_files = [] - -# The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 - -# Allow duplicate toc entries. -#epub_tocdup = True - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'python': ('https://docs.python.org/3/', None)} diff --git a/setup.py b/setup.py index 13cafcd..5f80815 100644 --- a/setup.py +++ b/setup.py @@ -118,9 +118,10 @@ def _read_file(filename): author_email="zodb-dev@zope.org", url="https://github.com/zopefoundation/persistent/", project_urls={ - 'Documentation': 'https://persistent.readthedocs.io', - 'Issue Tracker': 'https://github.com/zopefoundation/persistent/issues', - 'Sources': 'https://github.com/zopefoundation/persistent', + 'Documentation': 'https://persistent.readthedocs.io', + 'Issue Tracker': 'https://github.com/zopefoundation/' + 'persistent/issues', + 'Sources': 'https://github.com/zopefoundation/persistent', }, license="ZPL 2.1", packages=find_packages('src'), diff --git a/src/persistent/persistence.py b/src/persistent/persistence.py index 3f84a99..1cf7d40 100644 --- a/src/persistent/persistence.py +++ b/src/persistent/persistence.py @@ -585,7 +585,7 @@ def __repr__(self): try: return p_repr(self) except Exception as e: - p_repr_str = ' _p_repr {!r}'.format(e) + p_repr_str = f' _p_repr {e!r}' oid = _OGA(self, '_Persistent__oid') jar = _OGA(self, '_Persistent__jar') @@ -596,17 +596,17 @@ def __repr__(self): if oid is not None: try: if isinstance(oid, bytes) and len(oid) == 8: - oid_str = ' oid 0x{:x}'.format(_OID_UNPACK(oid)[0]) + oid_str = f' oid 0x{_OID_UNPACK(oid)[0]:x}' else: - oid_str = ' oid {!r}'.format(oid) + oid_str = f' oid {oid!r}' except Exception as e: - oid_str = ' oid {!r}'.format(e) + oid_str = f' oid {e!r}' if jar is not None: try: - jar_str = ' in {!r}'.format(jar) + jar_str = f' in {jar!r}' except Exception as e: - jar_str = ' in {!r}'.format(e) + jar_str = f' in {e!r}' cls = self.__class__ return '<{}.{} object at 0x{:x}{}{}{}>'.format( diff --git a/src/persistent/picklecache.py b/src/persistent/picklecache.py index 325af8d..9fe4bef 100644 --- a/src/persistent/picklecache.py +++ b/src/persistent/picklecache.py @@ -248,7 +248,7 @@ def __delitem__(self, oid): """ See IPickleCache. """ if not isinstance(oid, OID_TYPE): - raise TypeError('OID must be {}: {}'.format(OID_TYPE, oid)) + raise TypeError(f'OID must be {OID_TYPE}: {oid}') if oid in self.persistent_classes: del self.persistent_classes[oid] else: diff --git a/src/persistent/tests/cucumbers.py b/src/persistent/tests/cucumbers.py index b5e1f68..0996d88 100644 --- a/src/persistent/tests/cucumbers.py +++ b/src/persistent/tests/cucumbers.py @@ -19,7 +19,7 @@ def print_dict(d): d = sorted(d.items()) print('{%s}' % (', '.join( - [('{!r}: {!r}'.format(k, v)) for (k, v) in d] + [(f'{k!r}: {v!r}') for (k, v) in d] ))) diff --git a/src/persistent/tests/test_list.py b/src/persistent/tests/test_list.py index 2cc32ff..b4f27a3 100644 --- a/src/persistent/tests/test_list.py +++ b/src/persistent/tests/test_list.py @@ -56,8 +56,8 @@ def test_volatile_attributes_not_persisted(self): m.foo = 'bar' m._v_baz = 'qux' state = m.__getstate__() - self.assertTrue('foo' in state) - self.assertFalse('_v_baz' in state) + self.assertIn('foo', state) + self.assertNotIn('_v_baz', state) def testTheWorld(self): # Test constructors @@ -153,9 +153,9 @@ def mycmp(a, b): # Test __contains__ for i in u2: - self.assertTrue(i in u2, "i in u2") - for i in min(u2)-1, max(u2)+1: - self.assertTrue(i not in u2, "i not in u2") + self.assertIn(i, u2, "i in u2") + for i in min(u2) - 1, max(u2) + 1: + self.assertNotIn(i, u2, "i not in u2") # Test __delslice__ @@ -172,11 +172,13 @@ def mycmp(a, b): # Test __add__, __radd__, __mul__ and __rmul__ # self.assertTrue(u1 + [] == [] + u1 == u1, "u1 + [] == [] + u1 == u1") - self.assertTrue(u1 + [1] == u2, "u1 + [1] == u2") + self.assertEqual(u1 + [1], u2, "u1 + [1] == u2") # self.assertTrue([-1] + u1 == [-1, 0], "[-1] + u1 == [-1, 0]") - self.assertTrue(u2 == u2*1 == 1*u2, "u2 == u2*1 == 1*u2") - self.assertTrue(u2+u2 == u2*2 == 2*u2, "u2+u2 == u2*2 == 2*u2") - self.assertTrue(u2+u2+u2 == u2*3 == 3*u2, "u2+u2+u2 == u2*3 == 3*u2") + self.assertTrue(u2 == u2 * 1 == 1 * u2, "u2 == u2*1 == 1*u2") + self.assertTrue(u2 + u2 == u2 * 2 == 2 * u2, "u2+u2 == u2*2 == 2*u2") + self.assertTrue( + u2 + u2 + u2 == u2 * 3 == 3 * u2, + "u2+u2+u2 == u2*3 == 3*u2") # Test append @@ -205,7 +207,7 @@ def mycmp(a, b): eq(u, u1, "u == u1") # Test count - u = u2*3 + u = u2 * 3 eq(u.count(0), 3, "u.count(0) == 3") eq(u.count(1), 3, "u.count(1) == 3") eq(u.count(2), 0, "u.count(2) == 0") diff --git a/src/persistent/tests/test_mapping.py b/src/persistent/tests/test_mapping.py index d96b9ac..1962576 100644 --- a/src/persistent/tests/test_mapping.py +++ b/src/persistent/tests/test_mapping.py @@ -71,8 +71,8 @@ def test_volatile_attributes_not_persisted(self): m.foo = 'bar' m._v_baz = 'qux' state = m.__getstate__() - self.assertTrue('foo' in state) - self.assertFalse('_v_baz' in state) + self.assertIn('foo', state) + self.assertNotIn('_v_baz', state) def testTheWorld(self): # Test constructors @@ -163,9 +163,9 @@ def mycmp(a, b): # Test __contains__ for i in u2: - self.assertTrue(i in u2, "i in u2") + self.assertIn(i, u2, "i in u2") for i in min(u2) - 1, max(u2) + 1: - self.assertTrue(i not in u2, "i not in u2") + self.assertNotIn(i, u2, "i not in u2") # Test update @@ -175,9 +175,9 @@ def mycmp(a, b): for i in u: self.assertTrue(i in l_ or i in u2, "i in l or i in u2") for i in l_: - self.assertTrue(i in u, "i in u") + self.assertIn(i, u, "i in u") for i in u2: - self.assertTrue(i in u, "i in u") + self.assertIn(i, u, "i in u") # Test setdefault @@ -186,13 +186,13 @@ def mycmp(a, b): x = u2.setdefault(5, 5) eq(x, 5, "u2.setdefault(5, 5) == 5") - self.assertTrue(5 in u2, "5 in u2") + self.assertIn(5, u2, "5 in u2") # Test pop x = u2.pop(1) eq(x, 1, "u2.pop(1) == 1") - self.assertTrue(1 not in u2, "1 not in u2") + self.assertNotIn(1, u2, "1 not in u2") with self.assertRaises(KeyError): u2.pop(1) @@ -204,8 +204,8 @@ def mycmp(a, b): items = list(u2.items()) key, value = u2.popitem() - self.assertTrue((key, value) in items, "key, value in items") - self.assertTrue(key not in u2, "key not in u2") + self.assertIn((key, value), items, "key, value in items") + self.assertNotIn(key, u2, "key not in u2") # Test clear diff --git a/src/persistent/tests/test_persistence.py b/src/persistent/tests/test_persistence.py index 8d91266..c9f844a 100644 --- a/src/persistent/tests/test_persistence.py +++ b/src/persistent/tests/test_persistence.py @@ -189,7 +189,7 @@ def test_assign_p_jar_w_valid_jar(self): inst = self._makeOne() inst._p_jar = jar self.assertEqual(inst._p_status, 'saved') - self.assertTrue(inst._p_jar is jar) + self.assertIs(inst._p_jar, jar) inst._p_jar = jar # reassign only to same DM def test_assign_p_jar_not_in_cache_allowed(self): @@ -1066,42 +1066,42 @@ class Derived(self._getTargetClass()): key1 = 'key' key2 = 'ke' key2 += 'y' # construct in a way that won't intern the literal - self.assertFalse(key1 is key2) + self.assertIsNot(key1, key2) inst1.__setstate__({key1: 1}) inst2.__setstate__({key2: 2}) key1 = list(inst1.__dict__.keys())[0] key2 = list(inst2.__dict__.keys())[0] - self.assertTrue(key1 is key2) + self.assertIs(key1, key2) inst1 = Derived() inst2 = Derived() key1 = 'key' key2 = 'ke' key2 += 'y' # construct in a way that won't intern the literal - self.assertFalse(key1 is key2) + self.assertIsNot(key1, key2) state1 = IterableUserDict({key1: 1}) state2 = IterableUserDict({key2: 2}) k1 = list(state1.keys())[0] k2 = list(state2.keys())[0] - self.assertFalse(k1 is k2) # verify + self.assertIsNot(k1, k2) # verify inst1.__setstate__(state1) inst2.__setstate__(state2) key1 = list(inst1.__dict__.keys())[0] key2 = list(inst2.__dict__.keys())[0] - self.assertTrue(key1 is key2) + self.assertIs(key1, key2) def test___setstate___doesnt_fail_on_non_string_keys(self): class Derived(self._getTargetClass()): pass inst1 = Derived() inst1.__setstate__({1: 2}) - self.assertTrue(1 in inst1.__dict__) + self.assertIn(1, inst1.__dict__) class MyStr(str): pass mystr = MyStr('mystr') inst1.__setstate__({mystr: 2}) - self.assertTrue(mystr in inst1.__dict__) + self.assertIn(mystr, inst1.__dict__) def test___setstate___doesnt_fail_on_non_dict(self): class Derived(self._getTargetClass()): @@ -1116,7 +1116,7 @@ class Derived(self._getTargetClass()): def test___reduce__(self): inst = self._makeOne() first, second, third = inst.__reduce__() - self.assertTrue(first is copyreg.__newobj__) + self.assertIs(first, copyreg.__newobj__) self.assertEqual(second, (self._getTargetClass(),)) self.assertEqual(third, None) @@ -1126,7 +1126,7 @@ def __getnewargs__(self): return ('a', 'b') inst = Derived() first, second, third = inst.__reduce__() - self.assertTrue(first is copyreg.__newobj__) + self.assertIs(first, copyreg.__newobj__) self.assertEqual(second, (Derived, 'a', 'b')) self.assertEqual(third, {}) @@ -1136,7 +1136,7 @@ def __getstate__(self): return {} inst = Derived() first, second, third = inst.__reduce__() - self.assertTrue(first is copyreg.__newobj__) + self.assertIs(first, copyreg.__newobj__) self.assertEqual(second, (Derived,)) self.assertEqual(third, {}) @@ -1149,7 +1149,7 @@ def __getstate__(self): return {'foo': 'bar'} inst = Derived() first, second, third = inst.__reduce__() - self.assertTrue(first is copyreg.__newobj__) + self.assertIs(first, copyreg.__newobj__) self.assertEqual(second, (Derived, 'a', 'b')) self.assertEqual(third, {'foo': 'bar'}) @@ -1702,8 +1702,8 @@ def inc(self): p = P() p.inc() p.inc() - self.assertTrue('x' in p.__dict__) - self.assertTrue(p._p_jar is None) + self.assertIn('x', p.__dict__) + self.assertIsNone(p._p_jar) def test_w_diamond_inheritance(self): class A(self._getTargetClass()): @@ -2218,7 +2218,7 @@ def test_w_non_type(self): def test_w_type(self): TO_CREATE = [type, list, tuple, object, dict] for typ in TO_CREATE: - self.assertTrue(isinstance(self._callFUT(typ), typ)) + self.assertIsInstance(self._callFUT(typ), typ) def test_suite(): diff --git a/src/persistent/tests/test_picklecache.py b/src/persistent/tests/test_picklecache.py index a2ce7a7..d701187 100644 --- a/src/persistent/tests/test_picklecache.py +++ b/src/persistent/tests/test_picklecache.py @@ -202,9 +202,9 @@ def test___setitem___non_ghost(self): self.assertEqual(_len(cache.klass_items()), 0) self.assertEqual(items[0][0], KEY) self.assertEqual(cache.ringlen(), 1) - self.assertTrue(items[0][1] is uptodate) - self.assertTrue(cache[KEY] is uptodate) - self.assertTrue(cache.get(KEY) is uptodate) + self.assertIs(items[0][1], uptodate) + self.assertIs(cache[KEY], uptodate) + self.assertIs(cache.get(KEY), uptodate) def test___setitem___persistent_class(self): @@ -263,7 +263,7 @@ def test___delitem___w_normal_object(self): cache[KEY] = uptodate del cache[KEY] - self.assertTrue(cache.get(KEY, self) is self) + self.assertIs(cache.get(KEY, self), self) def test___delitem___w_ghost(self): from persistent.interfaces import GHOST @@ -275,7 +275,7 @@ def test___delitem___w_ghost(self): cache[KEY] = ghost del cache[KEY] - self.assertTrue(cache.get(KEY, self) is self) + self.assertIs(cache.get(KEY, self), self) def test___delitem___w_remaining_object(self): cache = self._makeOne() @@ -288,8 +288,8 @@ def test___delitem___w_remaining_object(self): cache[UPTODATE] = uptodate del cache[UPTODATE] - self.assertTrue(cache.get(UPTODATE, self) is self) - self.assertTrue(cache.get(REMAINS, self) is remains) + self.assertIs(cache.get(UPTODATE, self), self) + self.assertIs(cache.get(REMAINS, self), remains) def test_lruitems(self): cache = self._makeOne() @@ -382,7 +382,7 @@ def test_full_sweep(self): self.assertEqual(cache.cache_non_ghost_count, 0) for oid in oids: - self.assertTrue(cache.get(oid) is None) + self.assertIsNone(cache.get(oid)) def test_full_sweep_clears_weakrefs_in_interface( self, sweep_method='full_sweep'): @@ -477,7 +477,7 @@ def test_minimize(self): self.assertEqual(cache.cache_non_ghost_count, 0) for oid in oids: - self.assertTrue(cache.get(oid) is None) + self.assertIsNone(cache.get(oid)) def test_minimize_turns_into_ghosts(self): from persistent.interfaces import GHOST @@ -533,7 +533,7 @@ def test_new_ghost_success_already_ghost(self): cache = self._makeOne(jar) candidate = self._makePersist(oid=None, jar=None) cache.new_ghost(KEY, candidate) - self.assertTrue(cache.get(KEY) is candidate) + self.assertIs(cache.get(KEY), candidate) self.assertEqual(candidate._p_oid, KEY) self.assertEqual(candidate._p_jar, jar) self.assertEqual(candidate._p_state, GHOST) @@ -546,7 +546,7 @@ def test_new_ghost_success_not_already_ghost(self): cache = self._makeOne(jar) candidate = self._makePersist(oid=None, jar=None, state=UPTODATE) cache.new_ghost(KEY, candidate) - self.assertTrue(cache.get(KEY) is candidate) + self.assertIs(cache.get(KEY), candidate) self.assertEqual(candidate._p_oid, KEY) self.assertEqual(candidate._p_jar, jar) self.assertEqual(candidate._p_state, GHOST) @@ -559,7 +559,7 @@ class Pclass: _p_jar = None cache = self._makeOne() cache.new_ghost(KEY, Pclass) - self.assertTrue(cache.get(KEY) is Pclass) + self.assertIs(cache.get(KEY), Pclass) self.assertEqual(Pclass._p_oid, KEY) return cache, Pclass, KEY @@ -571,7 +571,7 @@ class Pclass: _p_jar = None cache = self._makeOne() cache.new_ghost(KEY, Pclass) - self.assertTrue(cache.get(KEY) is Pclass) + self.assertIs(cache.get(KEY), Pclass) self.assertEqual(Pclass._p_oid, KEY) return cache, Pclass, KEY @@ -989,9 +989,9 @@ def test_full_sweep_w_sticky(self): self.assertEqual(cache.cache_non_ghost_count, 1) - self.assertTrue(cache.get(oids[0]) is not None) + self.assertIsNotNone(cache.get(oids[0])) for oid in oids[1:]: - self.assertTrue(cache.get(oid) is None) + self.assertIsNone(cache.get(oid)) def test_full_sweep_w_changed(self): from persistent.interfaces import CHANGED @@ -1005,9 +1005,9 @@ def test_full_sweep_w_changed(self): self.assertEqual(cache.cache_non_ghost_count, 1) - self.assertTrue(cache.get(oids[0]) is not None) + self.assertIsNotNone(cache.get(oids[0])) for oid in oids[1:]: - self.assertTrue(cache.get(oid) is None) + self.assertIsNone(cache.get(oid)) def test_init_with_cacheless_jar(self): # Sometimes ZODB tests pass objects that don't @@ -1084,7 +1084,7 @@ def test_reify_hit_single_ghost(self): self.assertEqual(cache.ringlen(), 1) items = cache.lru_items() self.assertEqual(items[0][0], KEY) - self.assertTrue(items[0][1] is candidate) + self.assertIs(items[0][1], candidate) self.assertEqual(candidate._p_state, UPTODATE) def test_cache_garbage_collection_bytes_also_deactivates_object(self): @@ -1125,8 +1125,8 @@ def _p_deactivate(self): # verify the change worked as expected self.assertEqual(cache.cache_size_bytes, 1) # verify our entrance assumption is fulfilled - self.assertTrue(cache.cache_size > 100) - self.assertTrue(cache.total_estimated_size > 1) + self.assertGreater(cache.cache_size, 100) + self.assertGreater(cache.total_estimated_size, 1) # A gc shrinks the bytes cache.incrgc() self.assertEqual(cache.total_estimated_size, 0) diff --git a/src/persistent/tests/test_ring.py b/src/persistent/tests/test_ring.py index a18b109..c9a47c0 100644 --- a/src/persistent/tests/test_ring.py +++ b/src/persistent/tests/test_ring.py @@ -30,7 +30,7 @@ def __init__(self): self._p_oid = self._next_oid() def __repr__(self): # pragma: no cover - return "".format(self._p_oid, id(self)) + return f"" class CFFIRingTests(unittest.TestCase): @@ -76,11 +76,11 @@ def test_delete_one_multiple(self): r.add(p) r.delete(p) self.assertEqual(0, len(r)) - self.assertFalse(p in r) + self.assertNotIn(p, r) r.delete(p) self.assertEqual(0, len(r)) - self.assertFalse(p in r) + self.assertNotIn(p, r) def test_delete_from_wrong_ring(self): r1 = self._makeOne() diff --git a/src/persistent/tests/test_timestamp.py b/src/persistent/tests/test_timestamp.py index 1413c22..a9db98a 100644 --- a/src/persistent/tests/test_timestamp.py +++ b/src/persistent/tests/test_timestamp.py @@ -147,7 +147,7 @@ def test_laterThan_self_is_later(self): ts1 = self._makeOne(SERIAL1) ts2 = self._makeOne(SERIAL2) later = ts2.laterThan(ts1) - self.assertTrue(later is ts2) + self.assertIs(later, ts2) def test_repr(self): SERIAL = b'\x01' * 8 @@ -378,25 +378,25 @@ def test_ordering(self): big_c = self._makeC(b'\x01\x00\x00\x00\x00\x00\x00\x00') big_py = self._makePy(b'\x01\x00\x00\x00\x00\x00\x00\x00') - self.assertTrue(small_py < big_py) - self.assertTrue(small_py <= big_py) + self.assertLess(small_py, big_py) + self.assertLessEqual(small_py, big_py) - self.assertTrue(small_py < big_c) - self.assertTrue(small_py <= big_c) - self.assertTrue(small_py <= small_c) + self.assertLess(small_py, big_c) + self.assertLessEqual(small_py, big_c) + self.assertLessEqual(small_py, small_c) - self.assertTrue(small_c < big_c) - self.assertTrue(small_c <= big_c) + self.assertLess(small_c, big_c) + self.assertLessEqual(small_c, big_c) - self.assertTrue(small_c <= big_py) - self.assertTrue(big_c > small_py) - self.assertTrue(big_c >= big_py) + self.assertLessEqual(small_c, big_py) + self.assertGreater(big_c, small_py) + self.assertGreaterEqual(big_c, big_py) - self.assertFalse(big_c == small_py) - self.assertFalse(small_py == big_c) + self.assertNotEqual(big_c, small_py) + self.assertNotEqual(small_py, big_c) - self.assertTrue(big_c != small_py) - self.assertTrue(small_py != big_c) + self.assertNotEqual(big_c, small_py) + self.assertNotEqual(small_py, big_c) def test_seconds_precision(self, seconds=6.123456789): # https://github.com/zopefoundation/persistent/issues/41 diff --git a/src/persistent/tests/test_wref.py b/src/persistent/tests/test_wref.py index 3a34bdf..8f4f924 100644 --- a/src/persistent/tests/test_wref.py +++ b/src/persistent/tests/test_wref.py @@ -26,25 +26,25 @@ def _makeOne(self, ob): def test_ctor_target_wo_jar(self): target = _makeTarget() wref = self._makeOne(target) - self.assertTrue(wref._v_ob is target) + self.assertIs(wref._v_ob, target) self.assertEqual(wref.oid, b'OID') - self.assertTrue(wref.dm is None) - self.assertFalse('database_name' in wref.__dict__) + self.assertIsNone(wref.dm) + self.assertNotIn('database_name', wref.__dict__) def test_ctor_target_w_jar(self): target = _makeTarget() target._p_jar = jar = _makeJar() wref = self._makeOne(target) - self.assertTrue(wref._v_ob is target) + self.assertIs(wref._v_ob, target) self.assertEqual(wref.oid, b'OID') - self.assertTrue(wref.dm is jar) + self.assertIs(wref.dm, jar) self.assertEqual(wref.database_name, 'testing') def test___call___target_in_volatile(self): target = _makeTarget() target._p_jar = _makeJar() wref = self._makeOne(target) - self.assertTrue(wref() is target) + self.assertIs(wref(), target) def test___call___target_in_jar(self): target = _makeTarget() @@ -52,14 +52,14 @@ def test___call___target_in_jar(self): jar[target._p_oid] = target wref = self._makeOne(target) del wref._v_ob - self.assertTrue(wref() is target) + self.assertIs(wref(), target) def test___call___target_not_in_jar(self): target = _makeTarget() target._p_jar = _makeJar() wref = self._makeOne(target) del wref._v_ob - self.assertTrue(wref() is None) + self.assertIsNone(wref()) def test___hash___w_target(self): target = _makeTarget() @@ -151,7 +151,7 @@ def test_ctor_w_adict_as_dict(self): value = jar['value'] = _makeTarget(oid='VALUE') value._p_jar = jar pwkd = self._makeOne({key: value}) - self.assertTrue(pwkd[key] is value) + self.assertIs(pwkd[key], value) def test_ctor_w_adict_as_items(self): jar = _makeJar() @@ -160,7 +160,7 @@ def test_ctor_w_adict_as_items(self): value = jar['value'] = _makeTarget(oid='VALUE') value._p_jar = jar pwkd = self._makeOne([(key, value)]) - self.assertTrue(pwkd[key] is value) + self.assertIs(pwkd[key], value) def test___getstate___empty(self): pwkd = self._makeOne(None) @@ -206,9 +206,9 @@ def test___setstate___empty(self): pwkd = self._makeOne(None) pwkd.__setstate__({'data': [(kref, value), (kref2, value2), (kref3, value3)]}) - self.assertTrue(pwkd[key] is value) - self.assertTrue(pwkd.get(key2) is None) - self.assertTrue(pwkd[key3] is value3) + self.assertIs(pwkd[key], value) + self.assertIsNone(pwkd.get(key2)) + self.assertIs(pwkd[key3], value3) def test___setitem__(self): jar = _makeJar() @@ -218,7 +218,7 @@ def test___setitem__(self): value._p_jar = jar pwkd = self._makeOne(None) pwkd[key] = value - self.assertTrue(pwkd[key] is value) + self.assertIs(pwkd[key], value) def test___getitem___miss(self): jar = _makeJar() @@ -240,7 +240,7 @@ def test___delitem__(self): value._p_jar = jar pwkd = self._makeOne([(key, value)]) del pwkd[key] - self.assertTrue(pwkd.get(key) is None) + self.assertIsNone(pwkd.get(key)) def test___delitem___miss(self): jar = _makeJar() @@ -261,14 +261,14 @@ def test_get_miss_w_explicit_default(self): value = jar['value'] = _makeTarget(oid='VALUE') value._p_jar = jar pwkd = self._makeOne(None) - self.assertTrue(pwkd.get(key, value) is value) + self.assertIs(pwkd.get(key, value), value) def test___contains___miss(self): jar = _makeJar() key = jar['key'] = _makeTarget(oid='KEY') key._p_jar = jar pwkd = self._makeOne(None) - self.assertFalse(key in pwkd) + self.assertNotIn(key, pwkd) def test___contains___hit(self): jar = _makeJar() @@ -277,7 +277,7 @@ def test___contains___hit(self): value = jar['value'] = _makeTarget(oid='VALUE') value._p_jar = jar pwkd = self._makeOne([(key, value)]) - self.assertTrue(key in pwkd) + self.assertIn(key, pwkd) def test___iter___empty(self): _makeJar() @@ -302,7 +302,7 @@ def test_update_w_other_pwkd(self): source = self._makeOne([(key, value)]) target = self._makeOne(None) target.update(source) - self.assertTrue(target[key] is value) + self.assertIs(target[key], value) def test_update_w_dict(self): jar = _makeJar() @@ -313,7 +313,7 @@ def test_update_w_dict(self): source = dict([(key, value)]) target = self._makeOne(None) target.update(source) - self.assertTrue(target[key] is value) + self.assertIs(target[key], value) def _makeTarget(oid=b'OID'): diff --git a/tox.ini b/tox.ini index 03f07e4..4f36d84 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,6 @@ envlist = coverage [testenv] -usedevelop = true pip_pre = py313: true deps = setuptools < 69 @@ -48,6 +47,7 @@ commands = python -c 'import os, subprocess; subprocess.check_call("coverage run -a -m zope.testrunner --test-path=src", env=dict(os.environ, PURE_PYTHON="0"), shell=True)' coverage html -i coverage report -i -m --fail-under=99.8 + [testenv:release-check] description = ensure that the distribution is ready to release basepython = python3 @@ -66,23 +66,14 @@ commands = twine check dist/* [testenv:lint] +description = This env runs all linters configured in .pre-commit-config.yaml basepython = python3 skip_install = true deps = - isort - flake8 -commands = - isort --check-only --diff {toxinidir}/src {toxinidir}/setup.py - flake8 src setup.py - -[testenv:isort-apply] -basepython = python3 -skip_install = true + pre-commit commands_pre = -deps = - isort commands = - isort {toxinidir}/src {toxinidir}/setup.py [] + pre-commit run --all-files --show-diff-on-failure [testenv:docs] basepython = python3