Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

An encrypted password store for use within pytest cases

Project description

PyPI version Python versions See Build Status on Travis CI

An encrypted password store for use within pytest cases

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.


Provide a way to include encrypted data in a test repo so project team members may share test account data (logins, password, keys) while only having to share the decryption password and store filename outside of the repository.


SecureStore makes use of PyAesCrypt by Marco Bellaccini: “pyAesCrypt is a Python 3 file-encryption module and script that uses AES256-CBC to encrypt/decrypt files and binary streams.”

Files must be formatted as YAML data (YAML Reference) and will be loaded into a Python dictionary.


You can install “pytest-securestore” via pip from PyPI:

$ pip install pytest-securestore


Generic YAML layout:

# a comment
    username: the_username
    password: a_password
    usertype: some_defined_type

Encrypt the YAML file (file encryption):

import os
import pyAesCrypt

buffer_size = 64 * 1024  # 64K
filename = os.getenv('SECURE_STORE_FILE')
password = os.getenv('SECURE_STORE_PASSWORD')
pyAesCrypt.encryptFile("/path/to/yaml/file", filename, password, buffer_size)

Include the encrypted file in the repository.

Within a test:

def test_get_store_values(store):
    # one way to get the value
    user = store.get('a_general_user')
    username = user['username']
    # or another
    username = store.get('a_general_user').get('username')
    # or even another
    password = store.get('a_general_user')['password']
    # or
    user_type = store['a_general_user']['usertype']
    # ...
    some_site.log_in(username, password, user_type)

And to kick it off:

CLI with environment variables:

$ pytest --secure-store-filename=$SECURE_STORE_FILE --secure-store-password=$SECURE_STORE_PASSWORD


Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-securestore” is free and open source software


If you encounter any problems, please file an issue along with a detailed description.

Project details

Download files

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

Files for pytest-securestore, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size pytest-securestore-0.1.3.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page