Skip to content

Commit

Permalink
Merge pull request #171 from lukpueh/fix-coveralls
Browse files Browse the repository at this point in the history
Fix publishing of coverage results to coveralls.io (+ misc test config updates)
  • Loading branch information
lukpueh authored Aug 8, 2019
2 parents f466266 + 8e8c95f commit 6ef6c61
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 64 deletions.
7 changes: 4 additions & 3 deletions tests/.coveragerc → .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[run]
branch = True

omit =
*/securesystemslib/_vendor/*
*/tests/*
*/site-packages/*

[report]
exclude_lines =
Expand All @@ -9,6 +13,3 @@ exclude_lines =
def _prompt
def __str__
if __name__ == .__main__.:

omit =
*/securesystemslib/_vendor/*
31 changes: 15 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
dist: xenial
language: python
dist: trusty
sudo: false
cache: pip
python: 3.6

env:
- TOXENV=py27
- TOXENV=py34
- TOXENV=py36
matrix:
include:
- python: "2.7"
env: TOXENV=py27
- python: "3.4"
env: TOXENV=py34
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36

before_script:
- pip install -U pip wheel tox
install:
- pip install -U tox coveralls

script: tox
script:
- tox

after_success:
- cd tests
- coveralls
- cd -

branches:
only:
- master
6 changes: 3 additions & 3 deletions ci-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cryptography
pynacl
tox
coverage
coveralls
six
colorama
mock; python_version < '3.3'
# Pin to versions supported by `coveralls` (see .travis.yml)
# https://github.com/coveralls-clients/coveralls-python/releases/tag/1.8.1
coverage<5.0
31 changes: 2 additions & 29 deletions tests/aggregate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Purpose>
Run all the unit tests from every .py file beginning with "test_" in
'tuf/tests'. Use --random to run the tests in random order.
'securesystemslib/tests'.
"""

# Help with Python 3 compatibility, where the print statement is a function, an
Expand All @@ -33,36 +33,9 @@

import sys
import unittest
import glob
import random

# 'unittest2' required for testing under Python < 2.7.
if sys.version_info >= (2, 7):
import unittest

else:
import unittest2 as unittest

# Generate a list of pathnames that match a pattern (i.e., that begin with
# 'test_' and end with '.py'. A shell-style wildcard is used with glob() to
# match desired filenames. All the tests matching the pattern will be loaded
# and run in a test suite.
tests_list = glob.glob('test_*.py')

# Remove '.py' from each filename to allow loadTestsFromNames() (called below)
# to properly load the file as a module.
tests_without_extension = []
for test in tests_list:
test = test[:-3]
tests_without_extension.append(test)

# Randomize the order in which the tests run. Randomization might catch errors
# with unit tests that do not properly clean up or restore monkey-patched
# modules.
random.shuffle(tests_without_extension)

if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromNames(tests_without_extension)
suite = unittest.TestLoader().discover("tests", top_level_dir=".")
all_tests_passed = unittest.TextTestRunner(verbosity=1).run(suite).wasSuccessful()
if not all_tests_passed:
sys.exit(1)
8 changes: 1 addition & 7 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
import shutil
import stat
import sys

# 'unittest2' required for testing under Python < 2.7.
if sys.version_info >= (2, 7):
import unittest

else:
import unittest2 as unittest
import unittest

# Use external backport 'mock' on versions under 3.3
if sys.version_info >= (3, 3):
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

[tox]
envlist = py27, py34, py35, py36
skipsdist = True

[testenv]
changedir = tests

commands =
coverage run --source securesystemslib aggregate_tests.py
coverage report -m --fail-under 100
install_command =
pip install --pre {opts} {packages}

deps =
-r{toxinidir}/ci-requirements.txt

install_command = pip install --pre {opts} {packages}
commands =
coverage run tests/aggregate_tests.py
coverage report -m --fail-under 100

0 comments on commit 6ef6c61

Please sign in to comment.