Skip to content

Test generation fails with Something went wrong in initial mypy run. #1798

@tyuldashev

Description

@tyuldashev

Description

UTBot cannot generate tests when source code located in folder withOUT __init__.py, it throws exception Something went wrong in initial mypy run.

To Reproduce

Steps to reproduce the behavior:

  1. Open attached project Python4.zip
  2. Invoke test generation for my_sum#main.py

Expected behavior

Tests are generated.

Actual behavior

Exception thrown, no tests are generated.

Even more when test generation invoked again, there is no even exception, tests are silently not generated.

Visual proofs (screenshots, logs, images)

java.lang.IllegalStateException: Something went wrong in initial mypy run. 
Python stderr Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Lib\site-packages\utbot_mypy_runner\__main__.py", line 29, in <module>
    stdout, stderr, exit_status, build_result = mypy_main.run(mypy_args)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\utbot_mypy_runner\mypy_main.py", line 131, in run
    return _run(lambda stdout, stderr: new_main(None, args=args,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\utbot_mypy_runner\mypy_main.py", line 121, in _run
    res = main_wrapper(stdout, stderr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\utbot_mypy_runner\mypy_main.py", line 131, in <lambda>
    return _run(lambda stdout, stderr: new_main(None, args=args,
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\utbot_mypy_runner\mypy_main.py", line 65, in new_main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\mypy\main.py", line 173, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\mypy\build.py", line 154, in build
    result = _build(
             ^^^^^^^
  File "C:\Python311\Lib\site-packages\mypy\build.py", line 230, in _build
    graph = dispatch(sources, manager, stdout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\mypy\build.py", line 2741, in dispatch
    write_deps_cache(rdeps, manager, graph)
  File "C:\Python311\Lib\site-packages\mypy\build.py", line 908, in write_deps_cache
    assert st.meta, "Module must be either parsed or cached"
AssertionError: Module must be either parsed or cached
Mypy stderr: null
	at org.utbot.python.newtyping.mypy.RunMypyKt.readMypyAnnotationStorageAndInitialErrors(RunMypy.kt:50)
	at org.utbot.python.PythonTestGenerationProcessor.processTestGeneration(PythonTestGenerationProcessor.kt:82)
	at org.utbot.python.PythonTestGenerationProcessor.processTestGeneration$default(PythonTestGenerationProcessor.kt:32)
	at org.utbot.intellij.plugin.language.python.PythonDialogProcessor$createTests$1.run(PythonDialogProcessor.kt:170)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:442)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$5(CoreProgressManager.java:493)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a buglang-pythonIssue is related to python supportstatus-verifiedBug fix is verified

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions