예제 #1
0
        public void GetModulesThatImportEverythingReturnsSysForFromSysImportAllStatement()
        {
            string           code      = "from sys import *";
            ParseInformation parseInfo = PythonParserHelper.CreateParseInfo(code);

            PythonResolverContext resolverContext = new PythonResolverContext(parseInfo);

            string[] expectedModules = new string[] { "sys" };
            Assert.AreEqual(expectedModules, resolverContext.GetModulesThatImportEverything());
        }
예제 #2
0
        public void GetModulesThatImportEverythingReturnsEmptyCollectionIfNotImportAll()
        {
            string           code      = "from math import tan";
            ParseInformation parseInfo = PythonParserHelper.CreateParseInfo(code);

            PythonResolverContext resolverContext = new PythonResolverContext(parseInfo);

            string[] expectedModules = new string[0];
            Assert.AreEqual(expectedModules, resolverContext.GetModulesThatImportEverything());
        }
예제 #3
0
        public void GetModulesThatImportEverythingIgnoresNonFromImportStatement()
        {
            string code =
                "import math\r\n" +
                "from sys import *";
            ParseInformation parseInfo = PythonParserHelper.CreateParseInfo(code);

            PythonResolverContext resolverContext = new PythonResolverContext(parseInfo);

            string[] expectedModules = new string[] { "sys" };
            Assert.AreEqual(expectedModules, resolverContext.GetModulesThatImportEverything());
        }