public virtual void AttachReplTest() { using (var interactive = Prepare(enableAttach: true)) { var app = interactive.App; var project = app.OpenProject(@"TestData\DebuggerProject.sln"); Assert.IsNotNull(PythonToolsPackage.GetStartupProject(app.ServiceProvider), "Startup project was not set"); Assert.IsTrue(interactive.Settings.EnableAttach, "EnableAttach was not set"); using (var dis = new DefaultInterpreterSetter(interactive.GetAnalyzer().InterpreterFactory)) { var activeDescr = app.GetService<UIThreadBase>().Invoke(() => project.GetPythonProject().GetInterpreterFactory().Configuration.Description); Assert.AreEqual(dis.CurrentDefault.Configuration.Description, activeDescr); interactive.Reset(); interactive.ClearScreen(); const string attachCmd = "$attach"; interactive.SubmitCode(attachCmd); app.OnDispose(() => { if (app.Dte.Debugger.CurrentMode != EnvDTE.dbgDebugMode.dbgDesignMode) { app.DismissAllDialogs(); try { app.ExecuteCommand("Debug.StopDebugging"); } catch (COMException) { } WaitForMode(app.Dte.Debugger, EnvDTE.dbgDebugMode.dbgDesignMode); } }); app.Dte.Debugger.Breakpoints.Add(File: "BreakpointTest.py", Line: 1); interactive.WaitForText(">" + attachCmd, ">"); WaitForMode(app.Dte.Debugger, EnvDTE.dbgDebugMode.dbgRunMode); interactive.Show(); const string import = "import BreakpointTest"; interactive.SubmitCode(import, wait: false); interactive.WaitForText(">" + attachCmd, ">" + import, ""); WaitForMode(app.Dte.Debugger, EnvDTE.dbgDebugMode.dbgBreakMode); Assert.AreEqual(EnvDTE.dbgEventReason.dbgEventReasonBreakpoint, app.Dte.Debugger.LastBreakReason); Assert.AreEqual(app.Dte.Debugger.BreakpointLastHit.FileLine, 1); app.ExecuteCommand("Debug.DetachAll"); WaitForMode(app.Dte.Debugger, EnvDTE.dbgDebugMode.dbgDesignMode); interactive.WaitForText(">" + attachCmd, ">" + import, "hello", ">"); } } }
public void DjangoCollectStaticFilesCommand() { using (var app = new PythonVisualStudioApp()) { var service = app.GetService<IComponentModel>(typeof(SComponentModel)).GetService<IInterpreterOptionsService>(); var envWithDjango = service.Interpreters.LastOrDefault(env => env.FindModulesAsync("django").WaitAndUnwrapExceptions().Contains("django")); if (envWithDjango == null) { Assert.Inconclusive("No available environments have Django installed"); } using (var dis = new DefaultInterpreterSetter(envWithDjango)) { var project = app.OpenProject("TestData\\DjangoApplication1\\DjangoApplication1.sln"); app.SolutionExplorerTreeView.SelectProject(project); app.Dte.ExecuteCommand("Project.CollectStaticFiles"); var console = app.GetInteractiveWindow("Django Management Console - " + project.Name); Assert.IsNotNull(console); console.WaitForTextEnd("The Python REPL process has exited", ">>> "); Assert.IsTrue(console.Text.Contains("0 static files copied")); } } }