Ale*_*lex 1 python unit-testing python-2.7 python-unittest
我的测试很简单。我想向两个不同的服务器发送两个请求,然后比较结果是否匹配。
我要测试以下内容。
I do not want to send the requests in setUp method because it will be send over and over for each new test. I would rather want to send the requests at the initialization. (maybe in the init method). But I found a lot of people were against that idea because they believe I should not override the init method for some reason. (I do not know exactly why) If that's the case, where should I send the requests? I am kind of against doing them in the class body (as shared variables).
A class method called before tests in an individual class run. setUpClass is called with the class as the only argument and must be decorated as a classmethod():
@classmethod
def setUpClass(cls):
...
Run Code Online (Sandbox Code Playgroud)
See: https://docs.python.org/3/library/unittest.html#unittest.TestCase.setUpClass
| 归档时间: |
|
| 查看次数: |
1611 次 |
| 最近记录: |