Unittest and CI in Python

Premise

Directory structure

project/
├── src/
│   └── module/
│       ├── __init__.py
│       └── add.py
├── test/
│   ├── module/
│   │   ├── __init__.py
│   │   └── test_add.py
│   └── __init__.py
└── .travis.yml

Contents

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

Unittest and CI in Python
Unittest in python
Stack and Queue in Python
MIDI packages in Python midi and pretty_midi
Difference between list () and [] in Python
Difference between == and is in python
View photos in Python and html
Sorting algorithm and implementation in Python
Manipulate files and folders in Python
About dtypes in Python and Cython
Assignments and changes in Python objects
Check and move directories in Python
Ciphertext in Python: IND-CCA2 and RSA-OAEP
Hashing data in R and Python
Python unittest module execution in vs2017
Function synthesis and application in Python
Export and output files in Python
Reverse Hiragana and Katakana in Python2.7
Reading and writing text in Python
[GUI in Python] PyQt5-Menu and Toolbar-
Create and read messagepacks in Python
Overlapping regular expressions in Python and Java
Quadtree in Python --2
Python in optimization
CURL in python
Differences in authenticity between Python and JavaScript
Metaprogramming in Python
Notes using cChardet and python3-chardet in Python 3.3.1.
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Modules and packages in Python are "namespaces"
Avoid nested loops in PHP and Python
Differences between Ruby and Python in scope
Meta-analysis in Python
difference between statements (statements) and expressions (expressions) in Python
Eigenvalues and eigenvectors: Linear algebra in Python <7>
Implementation module "deque" in queue and Python
Line graphs and scale lines in python
Differences in syntax between Python and Java
Check and receive Serial port in Python (Port check)
Search and play YouTube videos in Python
Epoch in Python
Difference between @classmethod and @staticmethod in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
Write O_SYNC file in C and Python
Dealing with "years and months" in Python
Plink in Python
Constant in python
Private methods and fields in python [encryption]
Find and check inverse matrix in Python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
Linear Independence and Basis: Linear Algebra in Python <6>
StepAIC in Python
Call sudo in Python and autofill password