示例#1
0
 def test_rename_reads_noop(self):
     src = 'aaa.bbb.ccc()'
     t = ast.parse(src)
     sc = scope.analyze(t)
     rename._rename_reads(sc, t, 'aaa.bbb.ccc.ddd', 'xxx.yyy')
     rename._rename_reads(sc, t, 'bbb.aaa', 'xxx.yyy')
     self.checkAstsEqual(t, ast.parse(src))
示例#2
0
 def test_rename_reads_noop(self):
     src = 'aaa.bbb.ccc()'
     t = pasta.ast_parse(src, py_ver)
     sc = scope.analyze(t, py_ver)
     rename._rename_reads(sc, t, 'aaa.bbb.ccc.ddd', 'xxx.yyy', py_ver)
     rename._rename_reads(sc, t, 'bbb.aaa', 'xxx.yyy', py_ver)
     self.checkAstsEqual(t, pasta.ast_parse(src, py_ver), py_ver)
示例#3
0
 def test_rename_reads_attribute(self):
     src = 'aaa.bbb.ccc()'
     t = pasta.ast_parse(src, py_ver)
     sc = scope.analyze(t, py_ver)
     rename._rename_reads(sc, t, 'aaa.bbb', 'xxx.yyy', py_ver)
     self.checkAstsEqual(t, pasta.ast_parse('xxx.yyy.ccc()', py_ver),
                         py_ver)
示例#4
0
 def test_rename_reads_type_annotation(self):
     src = textwrap.dedent("""\
     def foo(bar: 'aaa.bbb.ccc.Bar'):
       pass
     """)
     t = ast.parse(src)
     sc = scope.analyze(t)
     rename._rename_reads(sc, t, 'aaa.bbb', 'xxx.yyy')
     self.checkAstsEqual(
         t,
         ast.parse(
             textwrap.dedent("""\
     def foo(bar: 'xxx.yyy.ccc.Bar'):
       pass
     """)))
示例#5
0
 def test_rename_reads_name(self):
     src = 'aaa.bbb()'
     t = pasta.ast_parse(src, py_ver)
     sc = scope.analyze(t, py_ver)
     self.assertTrue(rename._rename_reads(sc, t, 'aaa', 'xxx', py_ver))
     self.checkAstsEqual(t, pasta.ast_parse('xxx.bbb()', py_ver),
                         py_ver)
示例#6
0
 def test_rename_reads_attribute(self):
     src = 'aaa.bbb.ccc()'
     t = ast.parse(src)
     sc = scope.analyze(t)
     rename._rename_reads(sc, t, 'aaa.bbb', 'xxx.yyy')
     self.checkAstsEqual(t, ast.parse('xxx.yyy.ccc()'))
示例#7
0
 def test_rename_reads_name(self):
     src = 'aaa.bbb()'
     t = ast.parse(src)
     sc = scope.analyze(t)
     self.assertTrue(rename._rename_reads(sc, t, 'aaa', 'xxx'))
     self.checkAstsEqual(t, ast.parse('xxx.bbb()'))