def setUp(self): MockerTestCase.setUp(self) self.data = { "handlercount": 0, "frequency": "", "handlerdir": self.makeDir(), "handlers": helpers.ContentHandlers(), "data": None} self.expected_module_name = "part-handler-%03d" % ( self.data["handlercount"],) expected_file_name = "%s.py" % self.expected_module_name expected_file_fullname = os.path.join(self.data["handlerdir"], expected_file_name) self.module_fake = FakeModule() self.ctype = None self.filename = None self.payload = "dummy payload" # Mock the write_file function write_file_mock = self.mocker.replace(util.write_file, passthrough=False) write_file_mock(expected_file_fullname, self.payload, 0600)
def setUp(self): MockerTestCase.setUp(self) self.data = { "handlercount": 0, "frequency": "", "handlerdir": self.makeDir(), "handlers": helpers.ContentHandlers(), "data": None } self.expected_module_name = "part-handler-%03d" % ( self.data["handlercount"], ) expected_file_name = "%s.py" % self.expected_module_name expected_file_fullname = os.path.join(self.data["handlerdir"], expected_file_name) self.module_fake = FakeModule() self.ctype = None self.filename = None self.payload = "dummy payload" # Mock the write_file function write_file_mock = self.mocker.replace(util.write_file, passthrough=False) write_file_mock(expected_file_fullname, self.payload, 0600)
def setUp(self): MockerTestCase.setUp(self) # we do not expect requests, but lets just prevent accidental # requests self.requests = self.mocker.replace('requests') self.expect(self.requests.request(ARGS, KWARGS)).count(0) self.proxy = self.mocker.mock(Proxy, count=False) ProxyMock = self.mocker.mock(count=False) self.expect(ProxyMock(ANY)).result(self.proxy) sm = get_current_registry() sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')
def setUp(self): MockerTestCase.setUp(self) # we do not expect requests, but lets just prevent accidental # requests self.requests = self.mocker.replace('requests') self.expect(self.requests.request(ARGS, KWARGS)).count(0) self.proxy = self.mocker.mock(Proxy, count=False) ProxyMock = self.mocker.mock(count=False) self.expect(ProxyMock(ANY)).result(self.proxy) sm = get_current_registry() sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='') self.stream = StringIO() self.handler = StreamHandler(self.stream) self.handler.setFormatter(Formatter('%(levelname)s %(message)s')) LOG.addHandler(self.handler) self.ori_log_level = LOG.getEffectiveLevel() LOG.setLevel(DEBUG)
def __init__(self, methodName="runTest"): MockerTestCase.__init__(self, methodName) self.resource_path = None
def tearDown(self): MockerTestCase.tearDown(self) sys.stdout = self.saved_stdout sys.stderr = self.saved_stderr
def setUp(self): MockerTestCase.setUp(self) self.saved_stdout = sys.stdout sys.stdout = StringIO.StringIO() self.saved_stderr = sys.stderr sys.stderr = StringIO.StringIO()
def setUp(self): MockerTestCase.setUp(self) self.requests = self.mocker.replace('requests') # this mocks any unexpected request: self.expect(self.requests.request(ARGS, KWARGS)).count(0)