Skip to main content

Clean tests for developers in a hurry

Project description

cleantest

A testing framework for developers who need clean environments in a hurry
Explore cleantest docs »

About

cleantest is a testing framework for quickly bringing up testing environments using the test authors hypervisor of choice. It was created out of NucciTheBoss's desire to efficiently test snap packages, Python code, and Juju charms without needing to make potentially system breaking modifications to the underlying host operating system.

Below is an outline of currently supported operating systems, Python versions, and hypervisors:

Supported operating systems Linux - yes Windows - not tested Mac - not tested
Supported python versions Python 3.8, 3.9, and 3.10 Wheel - yes
Supported hypervisors LXD - yes

Getting started

Installing cleantest

The recommended way to install cleantest is by downloading the published package on PyPI:

pip install cleantest

For those who wish to use the latest, bleeding-edge, and potentially unstable version cleantest of cleantest, the following command can be used to install cleantest from the main branch of this repository:

git clone https://github.com/NucciTheBoss/cleantest.git
cd cleantest
python3 -m pip install .

Configuring a test environment provider

Before you can start using cleantest to run tests, you need to set up a test environment provider. Currently, the only supported environment provider is LXD. You can set LXD up on your system using the following commands:

sudo snap install lxd
lxd init --auto

Run your first test

You can use any testing framework of your choice with cleantest, but this example will use pytest:

pip install pytest

Here is a test written using cleantest that you can download:

:clipboard: test.py
#!/usr/bin/env python3

"""A basic test"""

from cleantest.provider import lxd


@lxd(preserve=False)
def do_something():
    import sys

    try:
        import urllib
        sys.exit(0)
    except ImportError:
        sys.exit(1)


class TestSuite:
    def test_do_something(self) -> None:
        result = do_something()
        assert result.exit_code == 0

With the test file downloaded, run the test using pytest:

pytest test.py

Where to next?

Please the see the documentation for more information on all that you can do with cleantest.

Contributing

Please read through the contributing guidelines if you are interested in contributing to cleantest. Included are guidelines for opening issues, code formatting standards, and how to submit contributions to cleantest.

License

Code and documentation copyright © 2022 Jason C. Nucciarone, Canonical Ltd. Please see the Apache-2.0 license for more details.

Roadmap

Here are my (NucciTheBoss's) goals to get cleantest to release version 1.0.0:

  • Add support for injecting tests into LXD
  • Add support for multiple distros:
    • Ubuntu
    • Debian
    • CentOS
    • Rocky
    • Fedora
    • Arch
  • Enable support for running parallel tests with LXD
  • Better test logging capabilities
  • Support for a select few popular packaging formats:
    • Snap
    • Pip
    • Charm libraries
    • Debs, Rpms, Pacs, etc.
    • Apptainer
  • Robust hook mechanism -> i.e. an actual specification for hooks.
  • Comprehensive documentation

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

cleantest-0.3.0.tar.gz (35.5 kB view details)

Uploaded Source

Built Distribution

cleantest-0.3.0-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file cleantest-0.3.0.tar.gz.

File metadata

  • Download URL: cleantest-0.3.0.tar.gz
  • Upload date:
  • Size: 35.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cleantest-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e325e90fb37d03f207125aa210128c4accf15b2f72c697bc6b70c057941d77fe
MD5 01497f6ac4b75ab144404ce4f0045e2f
BLAKE2b-256 0e0c611c4d3bca318f2c679720c6ed43f4fa752c6fa97bcca81614651e317fc0

See more details on using hashes here.

File details

Details for the file cleantest-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cleantest-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 50.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for cleantest-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b01359065aa82c584101277045002561fa8ad70acd64784d17a12ae5d69df944
MD5 928b813db34c4af84dfebf100db24e52
BLAKE2b-256 15b2653cbba49b274df1a900eac227444f9d6cbf5a983d16fec8d5d561d8c080

See more details on using hashes here.

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