Python lib2to3.fixer_util.touch_import() Examples

The following are 30 code examples of lib2to3.fixer_util.touch_import(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module lib2to3.fixer_util , or try the search function .
Example #1
Source File: test_util.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #2
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #3
Source File: test_util.py    From android_universal with MIT License 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #4
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #5
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #6
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #7
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #8
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #9
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #10
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_after_docstring(self):
        node = parse('"""foo"""\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n') 
Example #11
Source File: test_util.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #12
Source File: test_util.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #13
Source File: test_util.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #14
Source File: test_util.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #15
Source File: test_util.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_after_docstring(self):
        node = parse('"""foo"""\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n') 
Example #16
Source File: test_util.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #17
Source File: test_util.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #18
Source File: test_util.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #19
Source File: test_util.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #20
Source File: test_util.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def test_after_docstring(self):
        node = parse('"""foo"""\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n') 
Example #21
Source File: test_util.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #22
Source File: test_util.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #23
Source File: test_util.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #24
Source File: test_util.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #25
Source File: test_util.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_after_docstring(self):
        node = parse('"""foo"""\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n') 
Example #26
Source File: test_util.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_name_import(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "cgi", node)
        self.assertEqual(str(node), 'import cgi\nbar()\n\n') 
Example #27
Source File: test_util.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_from_import(self):
        node = parse('bar()')
        fixer_util.touch_import("html", "escape", node)
        self.assertEqual(str(node), 'from html import escape\nbar()\n\n') 
Example #28
Source File: test_util.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_beginning(self):
        node = parse('bar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), 'import foo\nbar()\n\n') 
Example #29
Source File: test_util.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_after_imports(self):
        node = parse('"""foo"""\nimport bar\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n') 
Example #30
Source File: test_util.py    From datafari with Apache License 2.0 5 votes vote down vote up
def test_after_docstring(self):
        node = parse('"""foo"""\nbar()')
        fixer_util.touch_import(None, "foo", node)
        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n')