python
bash-3.2$ tree
.
├── hoge
│ ├── Hoge.py
│ └── __init__.py
├── setup.py
└── test
├── TestHoge.py
└── __init__.py
--Put the package source in ./hoge --Put the unit test code in ./test --Prepare init.py for each (the contents can be empty) --Python recognizes the "file itself" or "contains init.py files in subdirectories" located in each directory of sys.path as packages to be imported.
setup.py
I'm sorry ...
setup.py
from setuptools import setup, find_packages
setup(
name = "hoge",
version = "0.1",
packages = find_packages(),
test_suite = 'test'
)
Use unittest.
TestHoge.py
import unittest
from hoge import Hoge
class TestPiyo(unittest.TestCase):
def setUp(self):
self.obj = Hoge.Piyo()
def test_one(self):
self.assertEqual(1, self.obj.one())
def test_two(self):
self.assertEqual("two", self.obj.two())
Develop Hoge.py properly,
python
python setup.py test
Then the unit test is executed.
Recommended Posts