Add coverage with nose2 and coveralls

pull/754/head
Åke Forslund 2017-04-22 17:35:37 +02:00 committed by Augusto Monteiro 'Sparky
parent 92bc82be15
commit ac05fd4fd0
6 changed files with 18 additions and 4 deletions

2
.coveralls.yml Normal file
View File

@ -0,0 +1,2 @@
repo_token: 6xTyVRsaxpM3PkeCgjhqPu51CaBumfNia
service_name: travis-ci

1
.gitignore vendored
View File

@ -14,4 +14,5 @@ MANIFEST.in
setup.py
scripts/logs/*
logs/*
.coverage
mycroft/audio-accuracy-test/data/*

View File

@ -10,10 +10,15 @@ cache: pocketsphinx-python
install:
- VIRTUALENV_ROOT=${VIRTUAL_ENV} ./dev_setup.sh
- pip install -r requirements.txt
- pip install nose2 cov-core
- pip install python-coveralls
# - pip install -r test-requirements.txt
# command to run tests
script:
- pep8 mycroft test
- ./start.sh unittest --fail-on-error
- nose2 test --with-coverage --config=test/unittest.cfg
env:
- IS_TRAVIS=true
after_success:
coveralls

View File

@ -1,4 +1,4 @@
Mycroft [![Build Status](https://travis-ci.org/MycroftAI/mycroft-core.svg?branch=master)](https://travis-ci.org/MycroftAI/mycroft-core)
Mycroft [![Build Status](https://travis-ci.org/MycroftAI/mycroft-core.svg?branch=master)](https://travis-ci.org/MycroftAI/mycroft-core) [![Coverage Status](https://coveralls.io/repos/github/MycroftAI/mycroft-core/badge.svg?branch=dev)](https://coveralls.io/github/MycroftAI/mycroft-core?branch=dev)
==========
NOTE: The default branch for this repo is dev. This should be considered a working beta. If you want to clone a more stable version, switch over to the 'master' branch.

2
test/unittest.cfg Normal file
View File

@ -0,0 +1,2 @@
[unittest]
test-file-pattern=*.py

View File

@ -1,3 +1,4 @@
from os.path import dirname, join
import unittest
import json
from mycroft.util.json_helper import load_commented_json, uncomment_json
@ -6,12 +7,15 @@ from mycroft.util.json_helper import load_commented_json, uncomment_json
class TestFileLoad(unittest.TestCase):
def test_load(self):
root_dir = dirname(__file__)
# Load normal JSON file
with open('plain.json', 'rw') as f:
plainfile = join(root_dir, 'plain.json')
with open(plainfile, 'rw') as f:
data_from_plain = json.load(f)
# Load commented JSON file
data_from_commented = load_commented_json('commented.json')
commentedfile = join(root_dir, 'commented.json')
data_from_commented = load_commented_json(commentedfile)
# Should be the same...
self.assertEqual(data_from_commented, data_from_plain)