Browse files

Use the API to shutdown ZAP if the instance was not launched by the p…

…lugin
  • Loading branch information...
1 parent 3c94046 commit 10784d8b99811099f0a502b7d1d264b363781217 @davehunt committed Dec 12, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 pytest_zap.py
View
12 pytest_zap.py
@@ -337,8 +337,13 @@ def pytest_sessionfinish(session):
if not session.config._zap_config.has_option('control', 'stop') or\
session.config._zap_config.getboolean('control', 'stop'):
print '\nStopping ZAP'
- session.config.zap_process.kill()
- #TODO Use API to shutdown ZAP, fallback to killing the process
+ #TODO For now kill if we started the process, or use API if not
+ if hasattr(session.config, 'zap_process'):
+ session.config.zap_process.kill()
+ else:
+ zap.shutdown()
+
+# #TODO Use API to shutdown ZAP, fallback to killing the process
# zap.shutdown()
# timeout = 60
# end_time = time.time() + timeout
@@ -354,7 +359,10 @@ def pytest_sessionfinish(session):
# time.sleep(1)
# if(time.time() > end_time):
# print 'Timeout after %s seconds waiting for ZAP to shutdown.' % timeout
+# if hasattr(session.config, 'zap_process'):
# session.config.zap_process.kill()
+# else:
+# raise Exception('Unable to kill ZAP process.')
#TODO Fail if alerts were raised (unless in observation mode)

0 comments on commit 10784d8

Please sign in to comment.