project/
├── src/
│ └── module/
│ ├── __init__.py
│ └── add.py
├── test/
│ ├── module/
│ │ ├── __init__.py
│ │ └── test_add.py
│ └── __init__.py
└── .travis.yml
Write a module.
project/src/module/__init__.py
project/src/module/add.py
def add(a, b):
return a + b
I will write a spell.
project/test/__init__.py
import sys
sys.path.append('src')
Write a test (file name is test _ *. Py
).
project/test/module/__init__.py
project/test/module/test_add.py
import unittest
from module.add import add
class TestAdd(unittest.TestCase):
def test_add(self):
self.assertEqual(add(1, 2), 3)
if __name__ == '__main__':
unittest.main()
I will have you CI.
yaml:project/.travis.yml
language: python
python: 3.5
script: python -m unittest discover
Recommended Posts