use of org.sonar.plugins.python.api.symbols.ClassSymbol in project sonar-python by SonarSource.
the class ClassSymbolTest method unpacking_expression_as_parent.
@Test
public void unpacking_expression_as_parent() {
FileInput fileInput = parse("foo = (Something, SomethingElse)", "class C(*foo): ", " pass");
ClassDef classDef = (ClassDef) fileInput.statements().statements().get(1);
Symbol symbol = classDef.name().symbol();
assertThat(symbol instanceof ClassSymbol).isTrue();
assertThat(symbol.kind().equals(Symbol.Kind.CLASS)).isTrue();
ClassSymbol classSymbol = (ClassSymbol) symbol;
assertThat(classSymbol.superClasses()).hasSize(0);
assertThat(classSymbol.hasUnresolvedTypeHierarchy()).isTrue();
}
use of org.sonar.plugins.python.api.symbols.ClassSymbol in project sonar-python by SonarSource.
the class ClassSymbolTest method parent_has_multiple_bindings.
@Test
public void parent_has_multiple_bindings() {
FileInput fileInput = parse("class C: ", " pass", "C = \"hello\"", "class B(C): ", " pass");
ClassDef classDef = (ClassDef) fileInput.statements().statements().get(2);
Symbol symbol = classDef.name().symbol();
assertThat(symbol instanceof ClassSymbol).isTrue();
assertThat(symbol.kind().equals(Symbol.Kind.CLASS)).isTrue();
ClassSymbol classSymbol = (ClassSymbol) symbol;
assertThat(classSymbol.hasUnresolvedTypeHierarchy()).isTrue();
}
use of org.sonar.plugins.python.api.symbols.ClassSymbol in project sonar-python by SonarSource.
the class ClassSymbolTest method class_members_empty.
@Test
public void class_members_empty() {
ClassSymbol symbol = lastClassSymbol("class C: ", " pass");
assertThat(symbol.declaredMembers()).isEmpty();
}
use of org.sonar.plugins.python.api.symbols.ClassSymbol in project sonar-python by SonarSource.
the class ClassSymbolTest method parent_is_not_a_class.
@Test
public void parent_is_not_a_class() {
FileInput fileInput = parse("def foo():", " pass", "A = foo()", "class C(A): ", " pass");
ClassDef classDef = (ClassDef) fileInput.statements().statements().get(2);
Symbol symbol = classDef.name().symbol();
assertThat(symbol instanceof ClassSymbol).isTrue();
assertThat(symbol.kind().equals(Symbol.Kind.CLASS)).isTrue();
ClassSymbol classSymbol = (ClassSymbol) symbol;
assertThat(classSymbol.superClasses()).hasSize(1);
assertThat(classSymbol.hasUnresolvedTypeHierarchy()).isTrue();
}
use of org.sonar.plugins.python.api.symbols.ClassSymbol in project sonar-python by SonarSource.
the class ClassSymbolTest method builtin_parent_with_unknown.
@Test
public void builtin_parent_with_unknown() {
FileInput fileInput = parse("class C: ", " pass", "class B(C, BaseException, unknown): ", " pass");
ClassDef classDef = (ClassDef) fileInput.statements().statements().get(1);
Symbol symbol = classDef.name().symbol();
assertThat(symbol instanceof ClassSymbol).isTrue();
assertThat(symbol.kind().equals(Symbol.Kind.CLASS)).isTrue();
ClassSymbol classSymbol = (ClassSymbol) symbol;
assertThat(classSymbol.superClasses()).hasSize(2);
assertThat(classSymbol.hasUnresolvedTypeHierarchy()).isTrue();
}
Aggregations