Skip to main content

Pytest fixtures for testing with gnupg.

Project description



Pytest fixtures to dynamically create GnuPG instances for testing.

Getting Started

Update to include:

from distutils.core import setup


All fixtures should be automatically included via the pytest11 entry point.

from pytest_gnupg_fixtures import GnuPGKeypair  # Optional, for typing

def test_custom_signer(gnupg_keypair: GnuPGKeypair):
    custom_signer = CustomSigner(
    assert "PGP SIGNATURE" in custom_signer.sign("my data")
  • Tested with python 3.8



$ pip install pytest_gnupg_fixtures

From source code

$ git clone
$ cd pytest-gnupg-fixtures
$ virtualenv env
$ source env/bin/activate
$ python -m pip install --editable .[dev]



Provides a generated email to use as part of the uid for the keypair.


Provides the path to a templated GnuPG script file that is used to generate a temporary keypair. If a user-defined script (tests/gnupg_gen_key.conf) can be located, it is used. Otherwise, an embedded script template is copied to temporary location and returned. This fixture is used by the gnupg_keypair fixture.

The$GNUGP_EMAIL and $GNUPG_PASSPHRASE variables will be populated within the template during generation of the keypair.


Provides a keypair within a temporary GnuPG trust store.

NamedTuple Fields

The following fields are defined in the tuple provided by this fixture:

Typing is provided by pytest_gnupg_fixtures.GnuPGKeypair.


Provides a generated passphrase to use for the keypair.


Provides a temporary, initialized, GnuPG trust store that is contains no keys. This fixture is used by the gnupg_keypair fixture.

NamedTuple Fields

The following fields are defined in the tuple provided by this fixture:

  • gnupg_home - The path to the temporary trust store.

Typing is provided by pytest_gnupg_fixtures.GnuPGTrustStore.


  1. This has been coded to work with gpg2.
  2. The generated keypair is very simple. TBD if this will be expanded to support a more realistic configuration.


Source Control

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_gnupg_fixtures-0.1.6.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

pytest_gnupg_fixtures-0.1.6-py3-none-any.whl (11.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page