コード例 #1
0
        public virtual void ImportCompletions()
        {
            using (var interactive = Prepare()) {
                if (interactive.Settings.Version.IsIronPython)
                {
                    interactive.SubmitCode("import clr");
                }

                Keyboard.Type("import ");
                List <string> names;
                using (var sh = interactive.WaitForSession <ICompletionSession>()) {
                    names = sh.Session.SelectedCompletionSet.Completions.Select(c => c.DisplayText).ToList();
                }

                Console.WriteLine(string.Join(Environment.NewLine, names));

                foreach (var name in names)
                {
                    Assert.IsFalse(name.Contains('.'), name + " contained a dot");
                }

                Keyboard.Type("os.");
                using (var sh = interactive.WaitForSession <ICompletionSession>()) {
                    names = sh.Session.SelectedCompletionSet.Completions.Select(c => c.DisplayText).ToList();
                    AssertUtil.ContainsExactly(names, "path");
                }
                interactive.ClearInput();
            }
        }
コード例 #2
0
        public virtual void RegressionImportMultipleModules()
        {
            using (var interactive = Prepare()) {
                interactive.AddNewLineAtEndOfFullyTypedWord = true;

                Keyboard.Type("import ");

                using (var sh = interactive.WaitForSession <ICompletionSession>()) {
                    var names   = sh.Session.SelectedCompletionSet.Completions.Select(c => c.DisplayText).ToList();
                    var nameset = new HashSet <string>(names);

                    Assert.AreEqual(names.Count, nameset.Count, "Module names were duplicated");
                }
            }
        }
コード例 #3
0
        public virtual void Comments()
        {
            using (var interactive = Prepare()) {
                const string code = "# fob";
                Keyboard.Type(code + "\r");

                interactive.WaitForText(">" + code, ".");

                const string code2 = "# oar";
                Keyboard.Type(code2 + "\r");

                interactive.WaitForText(">" + code, "." + code2, ".");

                Keyboard.Type("\r");
                interactive.WaitForText(">" + code, "." + code2, ".", ">");
            }
        }
コード例 #4
0
        public virtual void NoSnippets()
        {
            // https://pytools.codeplex.com/workitem/2945 is the reason for
            // disabling snippets; https://pytools.codeplex.com/workitem/2947 is
            // where we will re-enable them when they work properly.
            using (var interactive = Prepare()) {
                int spaces    = interactive.TextView.Options.GetOptionValue(DefaultOptions.IndentSizeOptionId);
                int textWidth = interactive.Settings.PrimaryPrompt.Length + 3;

                int totalChars = spaces;
                while (totalChars < textWidth)
                {
                    totalChars += spaces;
                }

                Keyboard.Type("def\t");
                interactive.WaitForText(">def" + new string(' ', totalChars - textWidth));
            }
        }