Hacking on zope.meta¶
Getting the Code¶
The main repository for zope.meta is in the Zope Foundation
Github repository:
You can get a read-only checkout from there:
$ git clone https://github.com/zopefoundation/meta.git
or fork it and get a writeable checkout of your fork:
$ git clone git@github.com/jrandom/meta.git
Working in a Python virtual environment¶
Installing¶
You can use Python’s standard venv package to create lightweight Python
development environments, where you can run the tests using nothing more
than the python binary in a virtualenv. First, create a scratch
environment:
$ python3.12 -m venv /tmp/hack-zope.meta
Next, install this package in “development mod” in the newly-created environment:
$ /tmp/hack-zope.meta/bin/pip install -e .
Running the tests¶
You can install test tools using the test extra:
$ /tmp/hack-zope.meta/bin/pip install -e ".[test]"
That command installs the tools needed to run
the tests: in particular, the zope.testrunner (see
Using zope.testrunner) and
Coverage.py tools.
To run the tests via zope.testrunner:
$ /tmp/hack-zope.meta/bin/zope-testrunner --test-path=src
Running zope.testrunner.layer.UnitTests tests:
...
Running the tests under coverage lets you see how well the tests
cover the code:
$ /tmp/hack-zope.meta/bin/coverage run -m zope.testrunner \
--test-path=src
...
$ coverage report -i -m --fail-under=100
Name Stmts Miss Branch BrPart Cover Missing
----------------------------------------------------------------------------------
...
Building the documentation¶
zope.meta uses the nifty Sphinx documentation system
for building its docs. Using the same virtualenv you set up to run the
tests, you can build the docs:
The docs command alias downloads and installs Sphinx and its dependencies:
$ /tmp/hack-zope.meta/bin/pip install ".[docs]"
...
$ /tmp/hack-zope.meta/bin/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
...
build succeeded.
The HTML pages are in docs/_build/html.
Using tox¶
Running Tests on Multiple Python Versions¶
tox is a Python-based test automation tool designed to run tests against multiple Python versions. It creates a virtual environment for each configured version, installs the current package and configured dependencies into each environment, and then runs the configured commands.
zope.meta configures the following tox environments via
its tox.ini file:
The
lintenvironment runs various “code quality” tests on the source, and fails on any errors they find.The
pyXXandpypy3environments each build an environment from the corresponding Python version, installzope.metaand testing dependencies, and runs the tests. It then installsSphinxand runs the doctest snippets.The
coverageenvironment builds a virtual environment, installszope.metaand dependencies, installscoverage, and runs the tests with statement and branch coverage.The
docsenvironment builds a virtual environment, installszope.metaand dependencies, installsSphinxand dependencies, and then builds the docs and exercises the doctest snippets.
This example requires that you have a working python3.12 on your path,
as well as installing tox:
$ tox -e py312
py312: install_deps> python -I -m pip install 'setuptools<74' Sphinx
...
py312: commands[0]> zope-testrunner --test-path=src -vc
Running tests at level 1
Running zope.testrunner.layer.UnitTests tests:
Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
Running:
.....
Running tox with no arguments runs all the configured environments,
including building the docs and testing their snippets.
Contributing to zope.meta¶
Submitting a Bug Report¶
zope.meta tracks its bugs on Github:
Please submit bug reports and feature requests there.