示例#1
0
        public void DeleteVirtualEnv()
        {
            using (var app = new PythonVisualStudioApp())
                using (var procs = new ProcessScope("Microsoft.PythonTools.Analyzer"))
                    using (var dis = Init(app)) {
                        var options        = app.GetService <PythonToolsService>().GeneralOptions;
                        var oldAutoAnalyze = options.AutoAnalyzeStandardLibrary;
                        app.OnDispose(() => { options.AutoAnalyzeStandardLibrary = oldAutoAnalyze; options.Save(); });
                        options.AutoAnalyzeStandardLibrary = false;
                        options.Save();

                        var project = CreateTemporaryProject(app);

                        string   envName, envPath;
                        TreeNode env = app.CreateVirtualEnvironment(project, out envName, out envPath);

                        // Need to wait some more for the database to be loaded.
                        app.WaitForNoDialog(TimeSpan.FromSeconds(10.0));

                        for (int retries = 3; !procs.ExitNewProcesses() && retries >= 0; --retries)
                        {
                            Thread.Sleep(1000);
                            Console.WriteLine("Failed to close all analyzer processes (remaining retries {0})", retries);
                        }

                        env.Select();
                        using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                            removeDeleteDlg.Delete();
                        }

                        app.WaitForNoDialog(TimeSpan.FromSeconds(5.0));

                        app.OpenSolutionExplorer().WaitForChildOfProjectRemoved(
                            project,
                            Strings.Environments,
                            envName
                            );

                        var projectHome = (string)project.Properties.Item("ProjectHome").Value;
                        envPath = Path.Combine(projectHome, envPath);
                        for (int retries = 10;
                             Directory.Exists(envPath) && retries > 0;
                             --retries)
                        {
                            Thread.Sleep(1000);
                        }
                        Assert.IsFalse(Directory.Exists(envPath), envPath);
                    }
        }
示例#2
0
        public void DeleteVEnv(PythonVisualStudioApp app)
        {
            using (var procs = new ProcessScope("Microsoft.PythonTools.Analyzer"))
                using (var dis = InitPython3(app)) {
                    var project = CreateTemporaryProject(app);

                    TreeNode env = app.CreateProjectVirtualEnvironment(project, out string envName, out string envPath);

                    // Need to wait some more for the database to be loaded.
                    app.WaitForNoDialog(TimeSpan.FromSeconds(10.0));

                    for (int retries = 3; !procs.ExitNewProcesses() && retries >= 0; --retries)
                    {
                        Thread.Sleep(1000);
                        Console.WriteLine("Failed to close all analyzer processes (remaining retries {0})", retries);
                    }

                    env.Select();
                    using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                        removeDeleteDlg.Delete();
                    }

                    app.WaitForNoDialog(TimeSpan.FromSeconds(5.0));

                    app.OpenSolutionExplorer().WaitForChildOfProjectRemoved(
                        project,
                        Strings.Environments,
                        envName
                        );

                    for (int retries = 10;
                         Directory.Exists(envPath) && retries > 0;
                         --retries)
                    {
                        Thread.Sleep(1000);
                    }
                    Assert.IsFalse(Directory.Exists(envPath), envPath);
                }
        }