私が持っているものを簡素化するクラスの例を次に示します。
class.py
class MyClass(object):
@staticmethod
def getDictionary():
#some calculations, returns a dictionary
def checkConfiguration(self):
#some code
self.getDictionary()
#some other code
return value
そして今、私は単体テストを作成していますcheckConfiguration
:
classTest.py
import class
import unittest
class TestMyClass(unittest.TestCase):
def setUp(self):
self.classTest = class.MyClass()
def test_CheckConfiguration(self):
#What to put here?
元のCheckConfiguration
呼び出しgetDictionary
。test_CheckConfiguration(self)
が呼び出された場合getDictionary
、入力できる辞書を自動的に返す必要があることを伝える方法はありますか? 何かのようなもの:
def test_CheckConfiguration(self):
if method getDictionary is called:
return {'a':123, 'b':22}
checkValue = self.classTest.checkConfiguration()
私はJavaでこれが可能であることを知っていますが、それもこれも十分な経験がありません。ありがとうございました。