how to optimize the below code with a helper function

Ganesh Pal ganesh1pal at gmail.com
Mon Apr 4 04:04:59 EDT 2016


Hi Team,

Iam on python 2.7.10 and Linux.

I have a  python function where the similar kind of pattern repeating 100
of times

Sample code snippet:

test01_log = os.path.join(LOG_DIR, "test01.log")
        cls.get_baddr['test01'] = failure.run_tool(
            test01_log, object="inode", offset="18", size="4",
            optype="set")

test02_log = os.path.join(LOG_DIR, "test02.log")
        cls.get_baddr['test02'] = failure.run_tool(
            test02_log, lin=lin_02, object="lin", offset="100", size="5",
            optype="set")
 ..............................................------------------------

test100_log = os.path.join(LOG_DIR, "test100.log")
        cls.get_baddr['test100'] = failure.run_tool(
            test02_log, baddr=lin_02, object="baddr", offset="100", size="5",
            optype="set")


(1)  Any tips how I can optimize this i.e test case, should have a helper
function that all test cases call.

(2) Also note that failure.run_tool function can have variable number of
argments  how to handle this in the helper function?



Thanks in advance


Regards,

Ganesh



More information about the Python-list mailing list