Forum Discussion

JackSparrow's avatar
JackSparrow
Frequent Contributor
8 years ago
Solved

Importing a function from one unit to other [Python]

Hi All,

 

Am just starting to understand the python and test complete , after reading few article of support test complete i tried to import a function from one unit to other unit function.

 

In my Library(Unit) i have a function DB_Extract for extracting the data from DB in my main TestScript(other Unit) i have scripted for a test case Test_Case1 where in between i need to use DB_Extract Function.

 

So I used like this

 

###########Library(Unit)################
def DB_Extract(query,colname)
   #
   #
   #
  return

##################TestScript(OtherUnit)##############################
import Library
def Test_Case1():
  DB_Extract('select*from All','States')

Am facing an error" DB_Extract is not defined ".where did i went wrong any where .Kindly let me know

 

 

#################################################################################

I even tried Runner.CallMethod("Library.DBExtract") but how to pass the parameters

 

  • did you tried 

    Library.DB_Extract('select*from All','States')