Skip to content

Instantly share code, notes, and snippets.

@guerbai
Last active June 2, 2019 04:00
Show Gist options
  • Save guerbai/0b013991ce831407adb0a1853d085255 to your computer and use it in GitHub Desktop.
Save guerbai/0b013991ce831407adb0a1853d085255 to your computer and use it in GitHub Desktop.
python测试代码组织
import unittest
# 1situation.
def emailsuite():
suite = unittest.TestSuite()
tests = [
'test_normal_sendemail',
'test_no_dealnocb_work'
]
return unittest.TestSuite(map(testemail.EmailTestCase, tests))
# 2situation.
def emailsuite():
suite = unittest.TestSuite()
suite.addTest(testemail.EmailTestCase('test_normal_send_email'))
suite.addTest(testemail.EmailTestCase('test_no_dealnocb_work'))
return suite
# 2situation client.
suite1 = emailsuite()
alltests = unittest.TestSuite([suite1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment