-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Labels
comp-fuzzingIssue is related to the fuzzingIssue is related to the fuzzingctg-bugIssue is a bugIssue is a buglang-pythonIssue is related to python supportIssue is related to python support
Description
Description
Tests are not generated for classes that have inner classes.
To Reproduce
Steps to reproduce the behavior:
- Add this code to Python project:
class Outer:
class Inner:
a = 1
def inc(self):
self.a += 1
def __init__(self):
self.inner = Outer.Inner()
def inc1(self):
self.inner.inc()- Use plugin to generate tests
Expected behavior
Tests are supposed to be generated.
Actual behavior
Tests were not generated.
Visual proofs (screenshots, logs, images)
When test generation is started from CLI with --verbosity=DEBUG key, the following error is shown:
13:57:44.822 | DEBUG | PythonEngine | Traceback (most recent call last):
File "/tmp/UTBot/python-test-generation-07779351610767258346/tmp_27_run_inc1.py", line 5, in <module>
import easy_samples.sample_classes.Outer
ModuleNotFoundError: No module named 'easy_samples.sample_classes.Outer'; 'easy_samples.sample_classes' is not a package
Additional context
We have incorrect logic of getting module name for PythonClassId in utbot-python/src/main/kotlin/org/utbot/python/framework/api/python/util/PythonIdUtils.kt:4:
fun moduleOfType(typeName: String): String? {
val lastIndex = typeName.lastIndexOf('.')
return if (lastIndex == -1) null else typeName.substring(0, lastIndex)
}In this case it splits easy_samples.sample_classes.Outer.Inner into (easy_samples.sample_classes.Outer, Inner), but should be (easy_samples.sample_classes, Outer.Inner).
utbot_mypy_runner splits this correctly.
Metadata
Metadata
Assignees
Labels
comp-fuzzingIssue is related to the fuzzingIssue is related to the fuzzingctg-bugIssue is a bugIssue is a buglang-pythonIssue is related to python supportIssue is related to python support
Type
Projects
Status
Done