diff --git a/test/integration/QuickTestIM.py b/test/integration/QuickTestIM.py
index 560fed202..483a8b336 100755
--- a/test/integration/QuickTestIM.py
+++ b/test/integration/QuickTestIM.py
@@ -17,17 +17,18 @@
# along with this program. If not, see .
import unittest
+
+from defusedxml import xmlrpc
+xmlrpc.monkey_patch()
+
try:
- from xmlrpclib import ServerProxy
+ from xmlrpclib import ServerProxy # nosec
except ImportError:
from xmlrpc.client import ServerProxy
import time
import sys
import os
-from defusedxml import xmlrpc
-xmlrpc.monkey_patch()
-
sys.path.append("..")
sys.path.append(".")
diff --git a/test/integration/TestIM.py b/test/integration/TestIM.py
index 6b3beff6e..112b10d7b 100755
--- a/test/integration/TestIM.py
+++ b/test/integration/TestIM.py
@@ -17,8 +17,11 @@
# along with this program. If not, see .
import unittest
+from defusedxml import xmlrpc
+xmlrpc.monkey_patch()
+
try:
- from xmlrpclib import ServerProxy
+ from xmlrpclib import ServerProxy # nosec
except ImportError:
from xmlrpc.client import ServerProxy
@@ -26,9 +29,6 @@
import sys
import os
-from defusedxml import xmlrpc
-xmlrpc.monkey_patch()
-
sys.path.append("..")
sys.path.append(".")
diff --git a/test/loadtest/LoadTest.py b/test/loadtest/LoadTest.py
index a8747e556..d761dc90b 100755
--- a/test/loadtest/LoadTest.py
+++ b/test/loadtest/LoadTest.py
@@ -23,14 +23,14 @@
import os
import random
import datetime
+from defusedxml import xmlrpc
+xmlrpc.monkey_patch()
+
try:
- from xmlrpclib import ServerProxy
+ from xmlrpclib import ServerProxy # nosec
except ImportError:
from xmlrpc.client import ServerProxy
-from defusedxml import xmlrpc
-xmlrpc.monkey_patch()
-
sys.path.append("..")
sys.path.append(".")
diff --git a/test/loadtest/LoadTestR.py b/test/loadtest/LoadTestR.py
index 7f6219aff..1cabf7111 100755
--- a/test/loadtest/LoadTestR.py
+++ b/test/loadtest/LoadTestR.py
@@ -23,14 +23,14 @@
import os
import random
import datetime
+from defusedxml import xmlrpc
+xmlrpc.monkey_patch()
+
try:
- from xmlrpclib import ServerProxy
+ from xmlrpclib import ServerProxy # nosec
except ImportError:
from xmlrpc.client import ServerProxy
-from defusedxml import xmlrpc
-xmlrpc.monkey_patch()
-
sys.path.append("..")
sys.path.append(".")