Skip to main content

Pytest plugin to track and report system usage statistics

Project description

CI Docs Codecov Python Versions Python Wheel Code Style: black PyPI - License

What is Pytest System Statistics

It’s a pytest plugin, extracted from pytest-salt-factories, which tracks the test suite CPU and memory usage and, optionally, includes a report section including that data, for example:

test_proc_sys_stats.py::test_one PASSED                                                [100%]
----------------------------------- Processes Statistics ------------------------------------
  .......... System - CPU: 17.80 %  MEM: 29.70 % (Virtual Memory)  SWAP:  12.80 %
  .. Test Suite Run - CPU:  0.00 %  MEM:  0.05 % (RSS)  MEM SUM: 0.09 % (RSS)  CHILD PROCS: 2
  ...... FooProcess - CPU:  0.00 %  MEM:  0.02 % (RSS)  MEM SUM: 0.03 % (RSS)  CHILD PROCS: 1

==================================== 1 passed in 0.34s ======================================

Install

Installing Pytest System Statistics is as simple as:

python -m pip install pytest-system-statistics

Usage

Controlling the behaviour of the plugin is made through flags which are passed to pytest.

--sys-stats             Print System CPU and MEM statistics after each test execution.
--no-sys-stats          Do not print System CPU and MEM statistics after each test execution.
--sys-stats-no-children Don't include child processes memory statistics.
--sys-stats-uss-mem     Use the USS("Unique Set Size", memory unique to a process which
                        would be freed if the process was terminated) memory instead which
                        is more expensive to calculate.

Tracking Additional Processes

To include additional processes to track and report statistics against, simply add it to the session scoped stats_processes fixture, for example:

@pytest.fixture
def my_server_process(stats_processes):
    proc = subprocess.Popen(...)
    stats_processes.add("MyServerProcess", proc.pid)
    try:
        yield proc
    finally:
        stats_processes.remove("MyServerProcess")

Contributing

The pytest-system-statistics project team welcomes contributions from the community. For more detailed information, refer to CONTRIBUTING.

Documentation

The full documentation can be seen here.

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-system-statistics-1.0.0.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

pytest_system_statistics-1.0.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file pytest-system-statistics-1.0.0.tar.gz.

File metadata

  • Download URL: pytest-system-statistics-1.0.0.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.2.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for pytest-system-statistics-1.0.0.tar.gz
Algorithm Hash digest
SHA256 28142ec5108b9995e1eb0416ca27fc14c341e662374e21bfc464ef586688abc2
MD5 d4bad5c022e7b82638ffe27ca61bd77a
BLAKE2b-256 1a9c727e84df3ca8c999ddd5b6166c3f993044f6261057c495032d331fb4a09a

See more details on using hashes here.

File details

Details for the file pytest_system_statistics-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_system_statistics-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.2.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

File hashes

Hashes for pytest_system_statistics-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fbed2217499f3163c7df7334aeedd462af4fa33f652587b0fe3e6d99e9de002
MD5 04f8f402da7b481e030624eeab1f8d37
BLAKE2b-256 83542b8e5005116438cc24f876943b30d24b56c2c9f97ff6d96f9965e8900fb4

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