Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(40378)

Side by Side Diff: Lib/lib2to3/tests/test_util.py

Issue 2830: Copy cgi.escape() to html
Patch Set: Created 9 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/http/server.py ('k') | Lib/test/test_xml_etree.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ Test suite for the code in fixer_util """ 1 """ Test suite for the code in fixer_util """
2 2
3 # Testing imports 3 # Testing imports
4 from . import support 4 from . import support
5 5
6 # Python imports 6 # Python imports
7 import os.path 7 import os.path
8 8
9 # Local imports 9 # Local imports
10 from lib2to3.pytree import Node, Leaf 10 from lib2to3.pytree import Node, Leaf
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 fixer_util.touch_import(None, "foo", node) 561 fixer_util.touch_import(None, "foo", node)
562 self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\ n') 562 self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\ n')
563 563
564 def test_beginning(self): 564 def test_beginning(self):
565 node = parse('bar()') 565 node = parse('bar()')
566 fixer_util.touch_import(None, "foo", node) 566 fixer_util.touch_import(None, "foo", node)
567 self.assertEqual(str(node), 'import foo\nbar()\n\n') 567 self.assertEqual(str(node), 'import foo\nbar()\n\n')
568 568
569 def test_from_import(self): 569 def test_from_import(self):
570 node = parse('bar()') 570 node = parse('bar()')
571 fixer_util.touch_import("cgi", "escape", node) 571 fixer_util.touch_import("html", "escape", node)
572 self.assertEqual(str(node), 'from cgi import escape\nbar()\n\n') 572 self.assertEqual(str(node), 'from html import escape\nbar()\n\n')
573 573
574 def test_name_import(self): 574 def test_name_import(self):
575 node = parse('bar()') 575 node = parse('bar()')
576 fixer_util.touch_import(None, "cgi", node) 576 fixer_util.touch_import(None, "cgi", node)
577 self.assertEqual(str(node), 'import cgi\nbar()\n\n') 577 self.assertEqual(str(node), 'import cgi\nbar()\n\n')
578 578
579 class Test_find_indentation(support.TestCase): 579 class Test_find_indentation(support.TestCase):
580 580
581 def test_nothing(self): 581 def test_nothing(self):
582 fi = fixer_util.find_indentation 582 fi = fixer_util.find_indentation
583 node = parse("node()") 583 node = parse("node()")
584 self.assertEqual(fi(node), "") 584 self.assertEqual(fi(node), "")
585 node = parse("") 585 node = parse("")
586 self.assertEqual(fi(node), "") 586 self.assertEqual(fi(node), "")
587 587
588 def test_simple(self): 588 def test_simple(self):
589 fi = fixer_util.find_indentation 589 fi = fixer_util.find_indentation
590 node = parse("def f():\n x()") 590 node = parse("def f():\n x()")
591 self.assertEqual(fi(node), "") 591 self.assertEqual(fi(node), "")
592 self.assertEqual(fi(node.children[0].children[4].children[2]), " ") 592 self.assertEqual(fi(node.children[0].children[4].children[2]), " ")
593 node = parse("def f():\n x()\n y()") 593 node = parse("def f():\n x()\n y()")
594 self.assertEqual(fi(node.children[0].children[4].children[4]), " ") 594 self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
OLDNEW
« no previous file with comments | « Lib/http/server.py ('k') | Lib/test/test_xml_etree.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+