예제 #1
0
        public void RemoveVirtualEnv()
        {
            using (var app = new PythonVisualStudioApp())
                using (var dis = Init(app)) {
                    var project = CreateTemporaryProject(app);

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

                    env.Select();

                    using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                        removeDeleteDlg.Remove();
                    }

                    app.OpenSolutionExplorer().WaitForChildOfProjectRemoved(
                        project,
                        SR.GetString(SR.Environments),
                        envName
                        );

                    var projectHome = (string)project.Properties.Item("ProjectHome").Value;
                    envPath = Path.Combine(projectHome, envPath);
                    Assert.IsTrue(Directory.Exists(envPath), envPath);
                }
        }
예제 #2
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);
                    }
        }
예제 #3
0
        public void DeleteVirtualEnv()
        {
            using (var app = new PythonVisualStudioApp())
                using (var dis = Init(app)) {
                    var project = CreateTemporaryProject(app);

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

                    // Need to wait for analysis to complete before deleting - otherwise
                    // it will always fail.
                    for (int retries = 120;
                         Process.GetProcessesByName("Microsoft.PythonTools.Analyzer").Any() && retries > 0;
                         --retries)
                    {
                        Thread.Sleep(1000);
                    }

                    Assert.IsFalse(Process.GetProcessesByName("Microsoft.PythonTools.Analyzer").Any(), "Analyzer is still running");

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

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

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

                    app.OpenSolutionExplorer().WaitForChildOfProjectRemoved(
                        project,
                        SR.GetString(SR.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);
                }
        }
예제 #4
0
        public void RemoveVEnv(PythonVisualStudioApp app) {
            using (var dis = InitPython3(app)) {
                var project = CreateTemporaryProject(app);

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

                env.Select();

                using (var removeDeleteDlg = RemoveItemDialog.FromDte(app)) {
                    removeDeleteDlg.Remove();
                }

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

                Assert.IsTrue(Directory.Exists(envPath), envPath);
            }
        }
예제 #5
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);
                }
        }