本文整理汇总了Python中unittest.TestCase.setUp方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.setUp方法的具体用法?Python TestCase.setUp怎么用?Python TestCase.setUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestCase
的用法示例。
在下文中一共展示了TestCase.setUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.root = "/tmp/lstestdir/"
self.link_file_src = "/tmp/mylink.txt"
self.date_string = self.todays_date()
self.remove_folder_structure()
self.create_folder_structure()
示例2: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self._expandCalled = 0
self._collapseCalled = 0
self._lastExpanded = 0
self._lastCollapsed = 0
示例3: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
# file = open("./hello.py", "a+")
# file.write("\"\"\"this is a hello module\"\"\"")
# file.close()
from com.gmail.takashi316.lib.file import hello
self.applicationDirectory = ApplicationDirectory(hello)
示例4: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
gc.set_threshold(500, 10, 10)
self._started = False
self._ioloop = rpclib.ioloop()
rpclib.__IOLOOP__ = self._ioloop
self._exc_info = None
示例5: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
from google.appengine.ext.testbed import Testbed
self.testbed = Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
示例6: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.tempdir = mkdtemp()
fd, self.tempfile = mkstemp()
os.close(fd)
self.reactor = Reactor()
self.port = PortNumberGenerator.next()
示例7: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
datadir = "../../data"
dist = ('Ubuntu', '12.10', 'quantal')
sys.path.insert(0, "..")
self._tApp = KazamApp(datadir, dist, False, False, False, False)
示例8: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
api._MANAGER = None
api._create_manager()
api._MANAGER.importers.add_plugin(IMPORTER_ID, MockImporter, {})
api._MANAGER.group_importers.add_plugin(GRP_IMPORTER_ID, MockGroupImporter, {})
api._MANAGER.distributors.add_plugin(DISTRIBUTOR_ID, MockDistributor, {})
api._MANAGER.group_distributors.add_plugin(GRP_DISTRIBUTOR_ID, MockGroupDistributor, {})
api._MANAGER.profilers.add_plugin(PROFILER_ID, MockProfiler, {}, TYPES)
api._MANAGER.catalogers.add_plugin(CATALOGER_ID, MockCataloger, {})
示例9: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self._sample1 = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'sample1')
with open(self._sample1, 'w') as wf:
wf.write(JSON_SAMPLE1)
self._sample2 = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'sample2')
with open(self._sample2, 'w') as wf:
wf.write(JSON_SAMPLE2)
self._sample3 = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'sample3')
示例10: setup_class
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setup_class(self):
""" real setup """
TestCase.setUp(self)
config_parser = ConfigReader('/home/pi/server/config/raspicam.cfg')
cfg = config_parser.parser()
# test in local(Rpi)
recmng = RecordMng(cfg.record)
vvpmng = VideoProcessMng(cfg.video)
self.testthr = threading.Thread(target=httpserve, \
args=(cfg, recmng, vvpmng))
self.testthr.setDaemon(True)
self.testthr.start()
示例11: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
UnitTestCase.setUp(self)
setup_test_environment()
if 'utrunner' not in sys.argv[0]:
self.skipTest('Only can run with unittest.')
self.client = Client()
self.client.login(username='jack', password='qwer1234')
print '.' * 100
print "<%s> currently run: %s" % (self.__class__.__name__, self._testMethodName)
print '.' * 100 + '\n'
示例12: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
try:
import webtest
except ImportError:
import setuptools.command.easy_install as easy_install
easy_install.main(["WebTest"])
exit()
self.test_app = webtest.TestApp(_wsgi_application)
from google.appengine.ext.testbed import Testbed
self.testbed = Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
示例13: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.fig = FiguraGeometrica()
#Retorna um NotImplementedError.
#O nome do método deve começar com test!
def test_get_area(self):
self.assertRaises(NotImplementedError, self.fig.get_area)
def test_get_perimetro(self):
self.assertRaises(NotImplementedError, self.fig.get_perimetro)
#Terei a verificação da execução dos métodos da classe FiguraGeometrica
#Como será uma classe abstrata, esses métodos serão vazios
#ou seja, os métodos devem ser implementados nas classes filhas dessa classe!
示例14: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
TestCase.setUp(self)
self.oldcwd = os.getcwd()
self.repo_parent = mkdtemp(prefix='test_git_')
self.prepare_repository(self.repo_parent, "meta-project-0.1")
self.repo_one = mkdtemp(prefix='test_git_')
self.prepare_repository(self.repo_one, "project-1.0.59", number_of_commits_since=1)
self.repo_two = mkdtemp(prefix='test_git_')
self.prepare_repository(self.repo_two, "secondproject-2.0", file_name="second.txt", number_of_commits_since=12)
os.chdir(self.repo_parent)
示例15: setUp
# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import setUp [as 别名]
def setUp(self):
"""Set up environment for tests.
When redefining this method in child classes, make sure to call it
before child's setup has started.
"""
TestCase.setUp(self)
logger = getLogger()
# Save existing data about logging system (log level and handlers)
self.__backup_loglevel = logger.getEffectiveLevel()
logger.setLevel(DEBUG)
self.__backup_log_handlers = []
for handler in logger.handlers:
self.__backup_log_handlers.append(handler)
logger.removeHandler(handler)
# Place test logger instead of them
self.__test_log_handler = TestLogHandler()
logger.addHandler(self.__test_log_handler)