def test_lambda_wait(): incman = Incrementor() ec, tc = wait_for(lambda self: self.i_sleep_a_lot() > 10, [incman], delay=.05) print "Function output %s in time %s " % (ec, tc) Assert.less(tc, 2, "Should take less than 2 seconds")
def test_simple_wait(): incman = Incrementor() ec, tc = wait_for(incman.i_sleep_a_lot, fail_condition=0, delay=.05) print "Function output %s in time %s " % (ec, tc) Assert.less(tc, 1, "Should take less than 1 seconds")
def test_sort_by_price_ascending_should_succeed(self): home_page = HomePage(self.driver).open_home_page() TV_page = home_page.header.open_TV_page() TV_page.sort_by_price_ascending() sleep(2) WebDriverWait(self.driver, 30).until(EC.invisibility_of_element_located(TV_page._processing_info)) Assert.less(TV_page.text_price_first_product(), TV_page.text_price_second_product())
def test_less_fail_int_message(self): try: Assert.less(2, 1, "message") except AssertionError as e: Assert.equal(e.msg, "message")
def test_less_fail_string_message(self): try: Assert.less("2", "1", "message") except AssertionError as e: Assert.equal(e.msg, "message")
def test_less_success(self): Assert.less("1", "2") Assert.less(1, 2)
def test_less_fail_int_message(self): try: Assert.less(2, 1, "message") except AssertionError, e: pass
def test_less_fail_string_message(self): try: Assert.less("2", "1", "message") except AssertionError, e: pass
def test_less_fail_int(self): try: Assert.less(2, 1) except AssertionError, e: pass
def test_lambda_wait(): incman = Incrementor() ec, tc = wait_for(lambda self: self.i_sleep_a_lot() > 2, [incman]) print "Function output %s in time %s " % (ec, tc) Assert.less(tc, 12, "Should take less than 12 seconds")
def test_simple_wait(): incman = Incrementor() ec, tc = wait_for(incman.i_sleep_a_lot, fail_condition=0) print "Function output %s in time %s " % (ec, tc) Assert.less(tc, 4, "Should take less than 4 seconds")