Skip to content

Commit

Permalink
added extra failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
maximiliankaul committed Dec 16, 2024
1 parent f7cdc01 commit 4bbdec0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import de.fraunhofer.aisec.cpg.InferenceConfiguration
import de.fraunhofer.aisec.cpg.analysis.ValueEvaluator
import de.fraunhofer.aisec.cpg.graph.*
import de.fraunhofer.aisec.cpg.graph.Annotation
import de.fraunhofer.aisec.cpg.graph.declarations.*
import de.fraunhofer.aisec.cpg.graph.declarations.FieldDeclaration
import de.fraunhofer.aisec.cpg.graph.declarations.FunctionDeclaration
import de.fraunhofer.aisec.cpg.graph.declarations.ParameterDeclaration
import de.fraunhofer.aisec.cpg.graph.declarations.VariableDeclaration
import de.fraunhofer.aisec.cpg.graph.statements.*
import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
import de.fraunhofer.aisec.cpg.graph.types.ListType
Expand Down Expand Up @@ -1451,6 +1454,36 @@ class PythonFrontendTest : BaseTest() {
assertTrue(pair.first)
}

@Test
fun testImportsWithoutDependencySource() {
val topLevel = Path.of("src", "test", "resources", "python")
val tu =
analyzeAndGetFirstTU(
listOf(topLevel.resolve("import_no_src_test.py").toFile()),
topLevel,
true
) {
it.registerLanguage<PythonLanguage>()
}
assertNotNull(tu)

val barCall = tu.calls["bar"]
assertIs<CallExpression>(barCall)
assertTrue(barCall.isImported.first)

val bazCall = tu.calls["baz"]
assertIs<CallExpression>(bazCall)
assertTrue(bazCall.isImported.first)

val fooCall = tu.calls["foo"]
assertIs<CallExpression>(fooCall)
assertTrue(fooCall.isImported.first)

val foo3Call = tu.calls["foo3"]
assertIs<CallExpression>(foo3Call)
assertTrue(foo3Call.isImported.first)
}

@Test
fun testInterfaceStubs() {
val topLevel = Path.of("src", "test", "resources", "python")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from foo import bar
from foo import bar as baz
import foo

bar()
baz()
foo.foo()
foo.foo2.foo3()

0 comments on commit 4bbdec0

Please sign in to comment.