いつもお世話になっております。
pythonのunittestについての質問です。
#やりたいこと
同名関数を呼び分けてテストしたい。
#前提
Python
1#target.py 2import bottle 3class Target: 4 @bottle.route('/info') 5 def config(): 6 #処理 7 8 @bottle.route('/info/id') 9 def config(id): 10 #処理
webで使うことを想定しているため、bottleフレームワークを使っております。
/info でIDの入力画面を表示させて、受け取ったIDを元に /info/id でさらに処理を行うようにしています。
上記のようなコードに対して、
Python
1#test_target.py 2from boddle import boddle 3import unittest 4from target import Target 5class TestTarget(unittest.TestCase): 6 with boddle(params={}): 7 #前処理 8 #config(id)ではなくconfig()を実行したい 9 Target.config() 10 #assert等 11if __name__ == "__main__": 12 unittest.main()
のような形で単体試験を行っているのですが、
実行すると
config() missing 1 required positional argument: 'id'
idの引数がないとのエラーが表示されました。
調べ方が悪いのか、同名の関数の呼び分け方がググっても出てきませんでした。
#試したこと
boddleのgithubの
You can also nest boddle calls. For instance:
の箇所から
python
1 with boddle(path='/info'): 2 with boddle(params={}):
も試してみましたが同じ結果となりました。
boddleでのunittestが初めてなので重要な点を見落としているかもしれませんが、
もし方法を知っている方がいましたらご教示いただけると幸いです。
#補足
python3.5.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/15 03:54