flow-control

How to determine if an exception was raised once you're in the finally block?

孤街醉人 提交于 2019-11-29 00:20:20
问题 Is it possible to tell if there was an exception once you're in the finally clause? Something like: try: funky code finally: if ???: print('the funky code raised') I'm looking to make something like this more DRY: try: funky code except HandleThis: # handle it raised = True except DontHandleThis: raised = True raise else: raised = False finally: logger.info('funky code raised %s', raised) I don't like that it requires to catch an exception, which you don't intend to handle, just to set a flag

How do you add a promise to the flow control queue using protractor?

筅森魡賤 提交于 2019-11-27 17:35:48
问题 In my test I am calling and outside library to seed data into our backend before running some ui tests using protractor. 'use strict' var dataBuilder = require('data_builder.js'); describe('test', function () { var testData = { name: 'foo', title: 'bar', ... }; beforeEach(function () { //create test data on the backend dataBuilder.create(testData).then(function (id) { testData.id = id.id; }); }); it('test something', function () { ... }); As such the promise returned by the dataBuilder isn't