Exemplo n.º 1
0
        internal static void InstallWebFramework(VisualStudioApp app, string moduleName, string packageName, IPythonInterpreterFactory factory)
        {
            var task = app.ServiceProvider.GetUIThread().InvokeTask(() =>
                                                                    Pip.Install(app.ServiceProvider, factory, packageName, false)
                                                                    );

            try {
                Assert.IsTrue(task.Wait(TimeSpan.FromMinutes(1.0)), "Timed out waiting for install " + packageName);
            } catch (AggregateException ex) {
                throw ex.InnerException;
            }
            Assert.AreEqual(1, InterpreterExt.FindModules(factory, moduleName).Count);
        }
Exemplo n.º 2
0
        public void WebProjectCreateVirtualEnvOnNew()
        {
            using (var app = new VisualStudioApp()) {
                var t = Task.Run(() => app.CreateProject(
                                     PythonVisualStudioApp.TemplateLanguageName,
                                     PythonVisualStudioApp.FlaskWebProjectTemplate,
                                     TestData.GetTempPath(),
                                     "WebProjectCreateVirtualEnvOnNew",
                                     suppressUI: false
                                     ));

                using (var dlg = new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog(t)))) {
                    // Create a virtual environment
                    dlg.ClickButtonAndClose("CommandLink_1000", nameIsAutomationId: true);
                }

                using (var dlg = new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog(t)))) {
                    dlg.ClickButtonByAutomationId("Create");
                    dlg.ClickButtonAndClose("Close", nameIsAutomationId: true);
                }

                var project = TaskExt.WaitAndUnwrapExceptions(t);

                var provider = project.Properties.Item("InterpreterFactoryProvider").Value as MSBuildProjectInterpreterFactoryProvider;
                for (int retries = 20; retries > 0; --retries)
                {
                    if (provider.IsProjectSpecific(provider.ActiveInterpreter))
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                Assert.IsTrue(provider.IsProjectSpecific(provider.ActiveInterpreter), "Did not have virtualenv");

                for (int retries = 60; retries > 0; --retries)
                {
                    if (InterpreterExt.FindModules(provider.ActiveInterpreter, "flask").Any())
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                AssertUtil.ContainsExactly(
                    InterpreterExt.FindModules(provider.ActiveInterpreter, "flask"),
                    "flask"
                    );
            }
        }
Exemplo n.º 3
0
        public void WebProjectInstallOnNew()
        {
            using (var app = new PythonVisualStudioApp()) {
                TaskExt.WaitAndUnwrapExceptions(
                    Pip.Uninstall(app.ServiceProvider, app.InterpreterService.DefaultInterpreter, "bottle", false)
                    );

                var t = Task.Run(() => app.CreateProject(
                                     PythonVisualStudioApp.TemplateLanguageName,
                                     PythonVisualStudioApp.BottleWebProjectTemplate,
                                     TestData.GetTempPath(),
                                     "WebProjectInstallOnNew",
                                     suppressUI: false
                                     ));

                using (var dlg = new AutomationDialog(app, AutomationElement.FromHandle(app.WaitForDialog(t)))) {
                    // Install to active environment
                    dlg.ClickButtonAndClose("CommandLink_1001", nameIsAutomationId: true);
                }

                var project = TaskExt.WaitAndUnwrapExceptions(t);

                var provider = project.Properties.Item("InterpreterFactoryProvider").Value as MSBuildProjectInterpreterFactoryProvider;

                Assert.AreSame(app.InterpreterService.DefaultInterpreter, provider.ActiveInterpreter);

                for (int retries = 60; retries > 0; --retries)
                {
                    if (InterpreterExt.FindModules(provider.ActiveInterpreter, "bottle").Any())
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }
                AssertUtil.ContainsExactly(
                    InterpreterExt.FindModules(provider.ActiveInterpreter, "bottle"),
                    "bottle"
                    );

                TaskExt.WaitAndUnwrapExceptions(
                    Pip.Uninstall(app.ServiceProvider, app.InterpreterService.DefaultInterpreter, "bottle", false)
                    );
            }
        }