Please take care to format the code properly, and make sure it reflects your actual code. Don’t just try to type out an example from memory; make sure you have something that can be run as is (no typos or syntax errors) and that will show the problem you are talking about (since you are not talking about a syntax error).
Making a best guess: I assume you actually have something like
test = "/home/test"
var = os.popen("test --version").read()
with the idea that test is the name of the program, and the variabletest also holds a path to a specific version of the program.
Python’s ordinary string literals will not care about any variables that you have in your program. If you want to substitute some variable’s text into a longer string, you have to write code for that explicitly. There are many ways to do this.