-
Notifications
You must be signed in to change notification settings - Fork 2
Functions to add functions
Test_Steps provides a way to add your own pass/fail functions via a simple way. addBioOperator, getOpWrapper
To add a pass/fail function, and map a operator to it. e.g.
addBiOperator('=d=', compDate)
This is to add compDate to the pass/fail functions (to add auto-log function), and =d= is the operator could be used in step/steps functions.
Return a pass/fail function using the op defined in addBiOperator.
For different product, or scenarios, some other operation you may want to define and add them for logging, it's easy based on this framework.
Define a comparing function for two expressions, e.g., to compare to date string
def compDate(date1, date2): import re pattern = re.compile(r'(\d+).(\d+).(\d+)') match1 = pattern.match(date1) match2 = pattern.match(date2) day1, month1, year1 = (int(i) for i in match1.group(1,2,3)) day2, month2, year2 = (int(i) for i in match2.group(1,2,3)) return (year1==year2) and (month1==month2) and (day1==day2) Register it into the test_steps framework:
addBiOperator('=d=', compDate) Get the opWapperFunction sameDate = getOpWrapper('=d=') Now, everything is good, you can write the following steps in your scripts now, and everything will be auto logged.
sameDate("01/03/2015", "1-3-2015", "description: this step should pass") check(" '03/05/2014' =d= '3/5/2014' ") Currently, just binary operators are supported.