Ok here’s my scenario (be kind, only been using Python for a short while):
I have a service I’m calling and need to run several iterations of the same test with a different variable passed to the method. I am able to run iterations against a single method just fine but I need the variable to change per each test and without counting the call to get a random variable as an iteration. I’m probably going about this the wrong way but I’d love any help I can get.
Here’s my code thus far:
data = ""
class MyTestWorkFlow:
global data
def Data(self):
low = 1
high = 1000
pid = random.randrange(low,high)
data = linecache.getline('c:/tmp/testData.csv', pid)
def Run(self):
client = Client(wsdl)
result = client.service.LookupData(data)
f = open('/tmp/content','w')
f.write (str(result))
f.close()
f = open('/tmp/content','r')
for i in f:
print i
f.close()
test = MyTestWorkFlow()
for i in range(1,2):
test.Run()
There’s a lot we could talk about regarding automated testing in Python, but the problem here is that you don’t seem to be invoking your
Datamethod.If you change your code like this:
does it do what you need?