示例#1
0
 def test_add_name_attr_const(self, code, is_str_annotation, expec_names,
                              expec_attrs):
     analyzer = scan.SourceAnalyzer([])
     analyzer._add_name_attr_const(ast.parse(code), is_str_annotation)
     source_stats, _ = analyzer.get_stats()
     self.assert_set_equal_or_not(source_stats.name_, expec_names)
     self.assert_set_equal_or_not(source_stats.attr_, expec_attrs)
示例#2
0
文件: test_scan.py 项目: chvmq/pycln
 def _get_analyzer(self, source_code: str):
     analyzer = scan.SourceAnalyzer(source_code.splitlines(True))
     if PY38_PLUS:
         ast_tree = ast.parse(source_code, type_comments=True)
     else:
         ast_tree = ast.parse(source_code)
     analyzer.visit(ast_tree)
     return analyzer
示例#3
0
文件: test_scan.py 项目: chvmq/pycln
 def test_get_end_lineno(self, code, lineno, is_parentheses, expec_end_lineno):
     analyzer = scan.SourceAnalyzer(code.splitlines(True))
     end_lineno = analyzer._get_end_lineno(lineno, is_parentheses)
     assert end_lineno == expec_end_lineno
示例#4
0
文件: test_scan.py 项目: chvmq/pycln
 def test_get_py38_import_from_node_py37_minus(self, code, expec_end_lineno):
     analyzer = scan.SourceAnalyzer(code.splitlines(True))
     self._assert_import_from_equal_py38(analyzer, code, expec_end_lineno)
示例#5
0
文件: test_scan.py 项目: chvmq/pycln
 def test_get_py38_import_from_node_py38_plus(self, code):
     analyzer = scan.SourceAnalyzer()
     self._assert_import_from_equal_py38(analyzer, code)
示例#6
0
文件: test_scan.py 项目: chvmq/pycln
 def test_init_py37_minus(self, source_lines, expec_error):
     # Test `__init__` dunder method for Python <3.8.
     with pytest.raises(expec_error):
         scan.SourceAnalyzer(source_lines)
         raise sysu.Pass()