porting test script to python