Esempio n. 1
0
 def test_should_return_undefined_symbols(self):
     self.assertEqual(findundefined.find_undefined
                      ("import os\n"
                       "os.path.join()\n"
                       "shutil.rmtree\n"
                       "shutil = 1"),
                      ["shutil.rmtree"])
Esempio n. 2
0
def _autoimport_add_imports(source):
    modules = []
    for name in findundefined.find_undefined(source):
        module = find_module_for(name)
        if module:
            modules.append(module)
    if modules:
        return add_imports(source, sorted(set(modules)))
    else:
        return None
Esempio n. 3
0
def _autoimport_add_imports(source):
    modules = []
    for name in findundefined.find_undefined(source):
        module = find_module_for(name)
        if module:
            modules.append(module)
    if modules:
        return add_imports(source, sorted(set(modules)))
    else:
        return None
Esempio n. 4
0
 def test_should_return_undefined_symbols(self):
     self.assertEqual(
         findundefined.find_undefined("import os\n"
                                      "os.path.join()\n"
                                      "shutil.rmtree\n"
                                      "shutil = 1"), ["shutil.rmtree"])
Esempio n. 5
0
 def test_should_not_return_duplicates(self):
     self.assertEqual(
         findundefined.find_undefined("sys.argv[1]\n"
                                      "sys.argv[2]\n"), ["sys.argv"])
Esempio n. 6
0
 def test(self):
     self.assertEqual(
         findundefined.find_undefined("import os\n" "os.path.join()\n" "shutil.rmtree\n" "shutil = 1"),
         ["shutil.rmtree"],
     )
Esempio n. 7
0
 def test_should_not_return_duplicates(self):
     self.assertEqual(findundefined.find_undefined
                      ("sys.argv[1]\n"
                       "sys.argv[2]\n"),
                      ["sys.argv"])