Skip to main content

Folds output sections in GitLab CI build log

Project description

pytest-gitlab-fold

Pytest plugin that folds output sections in GitLab CI build log.

It is a port of Eldar Abusalimov's excellent pytest-travis-fold plugin, all credits go to him and contributors.

GitLab CI build log view

In addition, pytest-gitlab-fold recognizes presence of the pytest-cov plugin and folds coverage reports accordingly.

Installation and Usage

Just install the pytest-gitlab-fold package as part of your build.

When using tox, add the package to the deps list in your tox.ini and make sure the GITLAB_CI environment variable is passed:

[testenv]
deps =
    pytest-gitlab-fold
passenv = GITLAB_CI

If you don't use tox and invoke py.test directly from .gitlab-ci.yml, you may install the package as an additional install step:

install:
  - pip install -e .
  - pip install pytest-gitlab-fold

script: py.test

Output folding is enabled automatically when running inside GitLab CI. It is OK to have the plugin installed also in your dev environment: it is only activated by checking the presence of the GITLAB_CI environmental variable, unless the --gitlab-fold command line switch is used.

The gitlab fixture

The plugin by itself only makes the captured output sections appear folded. If you wish to make the same thing with arbitrary lines, you can do it manually by using the gitlab fixture.

It is possible to fold the output of a certain code block using the gitlab.folding_output() context manager:

def test_something(gitlab):
    with gitlab.folding_output():
        print("Lines, lines, lines...")
        print("Lots of them!")
        ...

Or you may want to use lower-level gitlab.fold_string() and gitlab.fold_lines() functions and then output the result as usual.

Contributing

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.

License

Distributed under the terms of the MIT license, "pytest-gitlab-fold" is free and open source software.

Issues

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.

Source Distribution

pytest-gitlab-fold-0.3.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

pytest_gitlab_fold-0.3.0-py2.py3-none-any.whl (7.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-gitlab-fold-0.3.0.tar.gz.

File metadata

  • Download URL: pytest-gitlab-fold-0.3.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.66.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/1.5.0 colorama/0.4.6 CPython/3.9.17

File hashes

Hashes for pytest-gitlab-fold-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7841543539703e04770ed4a1b1ea8c0f8cfd7c4b99297eb3d698f9880dd3cb31
MD5 fde131ef666de46a8da2d9c178ef85c6
BLAKE2b-256 2a7aef011952ee427c757db864d4afdb84e06582593cf17f1055724eb0639e43

See more details on using hashes here.

File details

Details for the file pytest_gitlab_fold-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_gitlab_fold-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/1.26.15 tqdm/4.66.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/1.5.0 colorama/0.4.6 CPython/3.9.17

File hashes

Hashes for pytest_gitlab_fold-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b5e6c15f5e8556d43e22eb074576aa3bb5ee5ed4959493ee802106bb32a89e7f
MD5 e2d9210ba54cb78fdbd82df2241cf869
BLAKE2b-256 4fb6ed49c945957e8258181ad76a5464cfd509806b8dc3debd768c5f2f45354f

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