A free and easy way to set up a Python continuous integration environment
-Travis CI (free CI environment) -CoverAll (a service that allows you to view the coverage of code executed by Travis CI) -Slack (Chat service that receives notifications from Travis CI)
tests/hoge_test.py
tests/hoge_test.py
# coding:utf-8
import unittest
from fuga import Fuga
class HogeTest(unittest.TestCase):
def setUp(self):
print('setUp')
def test_first(self):
print('test_first')
def test_fuga(self):
fuga = Fuga()
self.assertTrue(fuga.index())
def suite():
suite = unittest.TestSuite()
suite.addTests(unittest.makeSuite(HogeTest))
return suite
tests/fuga.py
src/fuga.py
# coding utf-8
class Fuga:
def index(self):
return True
setup.py
sys.path.append ()
suite.addTests ()
in the code in test_suite
in the format of" testfile_name.suite "setup.py
from setuptools import setup, find_packages
import sys
sys.path.append('./src')
sys.path.append('./tests')
setup(
name = 'Hoge',
version = '0.1',
description='This is test codes for travis ci',
packages = find_packages(),
test_suite = 'hoge_test.suite'
)
.travis.yml
python:
version specificationscript:
coverage commandnotifications:
Notification settings for slackyaml:.travis.yml
language: python
python:
- 3.3
- 3.4
install:
- pip install coveralls
script:
- coverage run --source=hoge_test setup.py test
after_success:
- coveralls
notifications:
slack:
secure: your_token_key
-Refer to COVERALLS FOR PYTHON for cooperation with CoverAll. --See Configuring Build Notifications for notification settings. --See Encryption keys for how to encrypt your_token_key.
For the result display, refer to CI environment construction ~ PHP edition ~
Recommended Posts