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))
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)
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)
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 """)))
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)
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()'))
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()'))