It is the second print
line that throws the exception:
print self.tf.DUT.CheckTestFirmwareCommunication_SetPort()
The first print
line did not and was executed.
Python executes each statement within the try
suite, and only when one throws an exception, is execution aborted and transfers to the except
block. If you don't want the first print
statement to execute when CheckTestFirmwareCommunication_SetPort
throws an exception, call that method first:
self.tf.router.EchoProg(state=1)
try:
port = self.tf.DUT.CheckTestFirmwareCommunication_SetPort()
print "\tCheckTestFirmwareCommunication_SetPort: "
print port
except NoResponseException, e:
print "\tCheckTestFirmwareCommunication_SetPort: ", repr(e)
self.tf.router.EchoProg(state=0)