Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to verify TRAVIS_TAG agrees with project version during release #14

Merged
merged 4 commits into from
Jun 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Tests for example."""

import logging
import os
import sys
from unittest.mock import patch

Expand All @@ -26,18 +27,32 @@
pytest.param("critical2", marks=pytest.mark.xfail),
)

# define sources of version strings
TRAVIS_TAG = os.getenv("TRAVIS_TAG")
PROJECT_VERSION = example.__version__

def test_version(capsys):
"""Verify that version string sent to stdout, and agrees with the module."""

def test_stdout_version(capsys):
"""Verify that version string sent to stdout agrees with the module version."""
with pytest.raises(SystemExit):
with patch.object(sys, "argv", ["bogus", "--version"]):
example.example.main()
captured = capsys.readouterr()
assert (
captured.out == f"{example.__version__}\n"
captured.out == f"{PROJECT_VERSION}\n"
), "standard output by '--version' should agree with module.__version__"


@pytest.mark.skipif(
TRAVIS_TAG in [None, ""], reason="this is not a release (TRAVIS_TAG not set)"
)
def test_release_version():
"""Verify that release tag version agrees with the module version."""
assert (
TRAVIS_TAG == f"v{PROJECT_VERSION}"
), "TRAVIS_TAG does not match the project version"


@pytest.mark.parametrize("level", log_levels)
def test_log_levels(level):
"""Validate commandline log-level arguments."""
Expand Down