Пример #1
0
        public async Task FormatSelectionBlack()
        {
            var formatter          = new PythonFormatterBlack();
            var interpreterExePath = CreateVirtualEnv(formatter);

            var contents = @"a  = [0,  2, 3  ]
b =100 *2
";
            var filePath = CreateDocument(contents);

            var range = new Range()
            {
                Start = new Position(0, 0),
                End   = new Position(1, 0),
            };

            await formatter.FormatDocumentAsync(interpreterExePath, filePath, contents, range, new string[0]);
        }
Пример #2
0
        public async Task FormatDocumentBlack()
        {
            var python = PythonPaths.LatestVersion;

            if (python.Version < Microsoft.Python.Parsing.PythonLanguageVersion.V37)
            {
                // Black requires 37 or newer
                Assert.Inconclusive("Black formatting requires 37 or later");
            }

            var formatter          = new PythonFormatterBlack();
            var interpreterExePath = CreateVirtualEnv(formatter);

            var contents = @"a  = [0,  2, 3  ]
b =100 *2
";
            var filePath = CreateDocument(contents);

            var actual = await formatter.FormatDocumentAsync(interpreterExePath, filePath, contents, null, new string[0]);

            // We don't need to check correct formatting (as it changes with version) but rather
            // that it made any changes
            Assert.IsTrue(actual.Length > 0, "No actual edits performed by Black");
        }