ich bastle gerade an einem testskript wo ich ein komisches verhalten habe.
in der main methode wird folgendes aufgerufen:
Code: Alles auswählen
        self.setup_environment()
       .... do something with virtual box
      clean()
Code: Alles auswählen
        #store the original environment
        try:
            self.__old_user_home = os.environ['VBOX_USER_HOME']
        except KeyError:
            pass
        #set the VBOX_USER_HOME
        os.environ['VBOX_USER_HOME'] = self.__test_suite.get("General", "TEST_SUITE_VM_SETTING_FOLDER")
        #create the vbox_user_home folder, if not exist
        if not os.path.exists(os.environ['VBOX_USER_HOME']):
            os.makedirs(os.environ['VBOX_USER_HOME'])
        #save the orginal machine store of virtual box
        p1 = subprocess.Popen(["VBoxManage", "list", "systemproperties"],
                            env=os.environ.copy(),
                            stdout=subprocess.PIPE)
        p2 = subprocess.Popen(["grep", "Default machine folder:"],
                            env=os.environ.copy(),
                            stdout=subprocess.PIPE,
                            stdin=p1.stdout)
        p1.stdout.close()
        out = p2.communicate()[0]
        self.__old_machine_home = out.split(":")[1].strip()
        #set the machine store of virtual box
        set_command = ["VBoxManage", "setproperty", "machinefolder",
                        self.__test_suite.get("General", "TEST_SUITE_VM_STORE_FOLDER") ]
        subprocess.call(set_command, env=os.environ.copy())
        #create the machine store folder, if not exist
        if not os.path.exists(self.__test_suite.get("General", "TEST_SUITE_VM_STORE_FOLDER")):
            os.makedirs(self.__test_suite.get("General", "TEST_SUITE_VM_STORE_FOLDER"))
Code: Alles auswählen
    def clean(self):
...
            if os.path.exists(self.__test_suite.get("General", "TEST_SUITE_VM_STORE_FOLDER")):
            shutil.rmtree(self.__test_suite.get("General", "TEST_SUITE_VM_STORE_FOLDER"))
        if os.path.exists(self.__test_suite.get("General", "TEST_SUITE_VM_SETTING_FOLDER")):
            shutil.rmtree(self.__test_suite.get("General", "TEST_SUITE_VM_SETTING_FOLDER"))
Vielen Dank.
