diff --git a/tests/test_email.py b/tests/test_email.py
index 381bd2e5b436f3685ca099761e71bd468cc74d83..ecdb84e77de500f5288f51c7a9ff02e9d8e3d3c5 100755
--- a/tests/test_email.py
+++ b/tests/test_email.py
@@ -5,6 +5,7 @@ Criticality: High
 Check that emails can be sent.
 """
 
+from pathlib import Path
 import os
 import subprocess
 import sys
@@ -22,7 +23,7 @@ except ImportError:
 if subprocess.call(["which", "netstat"]) != 0:
     subprocess.check_call(["apt-get", "-qq", "-y", "install", "net-tools"])
 
-sys.path.append("..")
+sys.path.append(str(Path(__file__).parents[1].resolve()))
 
 # pylint: disable=wrong-import-position
 from envsetup import utils as u  # noqa: E402
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index 5767eca67362cfc76b85e1cc2f8e2615a111f462..47dfae2286aa07b884174da94c4e05c925194eea 100755
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -4,6 +4,7 @@ Criticality: High
 This test check the current state of the PostgreSQL database cluster.
 """
 
+from pathlib import Path
 import re
 import socket
 import subprocess
@@ -11,13 +12,13 @@ import sys
 import time
 import uuid
 
-sys.path.append("..")
-
 try:
     import psycopg2
 except ImportError:
     sys.exit(2)
 
+sys.path.append(str(Path(__file__).parents[1].resolve()))
+
 # pylint: disable=wrong-import-position
 from envsetup import utils as u  # noqa: E402