File tree Expand file tree Collapse file tree
test/patterns/assert_in_code Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: Copyright (c) 2019-2026 Aibolit
22# SPDX-License-Identifier: MIT
33
4- import os .path
5- from pathlib import Path
4+ from textwrap import dedent
65from unittest import TestCase
76
87from aibolit .patterns .assert_in_code .assert_in_code import AssertInCode
98from aibolit .ast_framework import AST
10- from aibolit .utils .ast_builder import build_ast
9+ from aibolit .utils .ast_builder import build_ast_from_string
1110
1211
1312class AssertInCodeTestCase (TestCase ):
14- cur_file_dir = Path (os .path .realpath (__file__ )).parent
15-
1613 def test_assert_in_code (self ):
17- file = Path (self .cur_file_dir , 'Book.java' )
18- ast = AST .build_from_javalang (build_ast (file ))
19- self .assertEqual (AssertInCode ().value (ast ), [6 ])
14+ content = dedent (
15+ '''\
16+ class Book {
17+ void foo(String x) {
18+ assert x != null; // here
19+ }
20+ }
21+ '''
22+ )
23+ ast = AST .build_from_javalang (build_ast_from_string (content ))
24+ self .assertEqual (AssertInCode ().value (ast ), [3 ])
You can’t perform that action at this time.
0 commit comments