Skip to content

Instantly share code, notes, and snippets.

@nicoddemus
Created February 24, 2017 21:03
Show Gist options
  • Save nicoddemus/47faeff936d51df21f04bdd8bc80ac60 to your computer and use it in GitHub Desktop.
Save nicoddemus/47faeff936d51df21f04bdd8bc80ac60 to your computer and use it in GitHub Desktop.
pytest plugin that shows environment variables when the build fails
def pytest_terminal_summary(terminalreporter, exitstatus):
import os
if exitstatus != 0 and 'JENKINS_URL' in os.environ:
markup = {'yellow': True, 'bold': True}
terminalreporter.write_sep("=", "ENVIRONMENT", **markup)
for k, v in sorted(os.environ.items()):
if k:
terminalreporter.write_line('%r: %r' % (k, v), **markup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment