diff test/test_dropbear.py @ 1863:b550845e500b

Use venv for test_aslr Otherwise we can't find the psutil dependency
author Matt Johnston <matt@ucc.asn.au>
date Sun, 30 Jan 2022 13:37:20 +0800
parents e0c1825c567d
children 49ce974c3215
line wrap: on
line diff
--- a/test/test_dropbear.py	Sun Jan 30 10:23:06 2022 +0800
+++ b/test/test_dropbear.py	Sun Jan 30 13:37:20 2022 +0800
@@ -57,6 +57,20 @@
 		# wait for response
 		return subprocess.run(full_args, **kwargs)
 
+def own_venv_command():
+	""" Returns a command to run as a prefix to get the same venv
+	as the current running Python. Returns '' on not a virtualenv
+	"""
+	try:
+		print(os.environ)
+		venv = os.environ['VIRTUAL_ENV']
+		print(venv)
+	except KeyError:
+		return ""
+
+	# note: bash/zsh unix specific
+	return f"source {venv}/bin/activate"
+
 class HandleTcp(socketserver.ThreadingMixIn, socketserver.TCPServer):
 	""" Listens for a single incoming request, sends a response if given,
 	and returns the inbound data.