Skip to main content

Write hooks for tox in a local file

Project description

With this plugin, local tox hook implementations can be defined in a file, which is in the same folder as the tox configuration file.

This will make it easier to write your own custom local hooks for tox. You just have to write the hooks in (instead of creating a plugin package starting with tox- and then installing it in the same location as tox).


tox.ini file

minversion = 3.8.0
requires = tox-local-hooks
skipsdist = true

whitelist_externals = bash
randpwdenv = TESTPASSWORD
commands = bash -c 'echo RANDOM PASSWORD: $TESTPASSWORD'

Then create the file in the same folder as tox-ini file

import pluggy, string, random

hookimpl = pluggy.HookimplMarker("tox")

def tox_addoption(parser):
        help="Random password environmental variable"

def tox_configure(config):
    for envConf in config.envconfigs.values():
        if envConf.randpwdenv:
            pwd = ''.join(random.choice(string.ascii_letters) for _ in range(10))
            envConf.setenv[envConf.randpwdenv] = pwd

While running tox, you should be able to see the following output

RANDOM PASSWORD: {some_random_string}

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 tox-local-hooks, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size tox-local-hooks-0.1.3.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page