Skip to content

No tests are generated for simple function with parameters without annotations #1819

Description

@tyuldashev

Description
Sometimes MyPy cannot properly guess type of parameters so starting to iterate over improper types till timeout occurs.

To Reproduce

class NoTestsProblem:
    def __init__(self):
        self.board = []

    def set_position(self, row, col, symbol):
        self.board[row][col] = symbol
        return symbol

    def start(self):
        self.set_position(1, 2, "O")

Steps to reproduce the behavior:

  1. Add to Python project the code above
  2. Invoke test generation for set_position function

Expected behavior

Tests are supposed to be generated.

Actual behavior

No test are generated.

Visual proofs (screenshots, logs, images)

idea.log contains following information:

2023-02-17 16:44:08,416 [6012745]   INFO - STDOUT - | UtBot - PythonTestCaseGenerator   | Inferred annotations: no_tests_bug.NoTestsProblem, builtins.str, builtins.list[typing.Any], builtins.list[typing.Any]
2023-02-17 16:44:08,418 [6012747]   INFO - STDOUT - | UtBot - PythonApi                 | Provider ReduceValueProvider accepts type no_tests_bug.NoTestsProblem
2023-02-17 16:44:08,419 [6012748]   INFO - STDOUT - | UtBot - PythonApi                 | Provider ListValueProvider accepts type builtins.list[typing.Any]
2023-02-17 16:44:08,419 [6012748]   INFO - STDOUT - | UtBot - PythonApi                 | Provider ConstantValueProvider accepts type builtins.list[typing.Any]
2023-02-17 16:44:08,419 [6012748]   INFO - STDOUT - | UtBot - PythonApi                 | Any does not have provider
202
...
....

2023-02-17 16:44:29,690 [6034019]   INFO - STDOUT - | UtBot - PythonEngine              | Evaluation with prohibited exception. Substituted types: no_tests_bug.NoTestsProblem, builtins.str, builtins.list[typing.Any], builtins.list[typing.Any]. Exception type: builtins.TypeError
2023-02-17 16:44:29,931 [6034260]   INFO - STDOUT - | UtBot - PythonEngine              | Evaluation with prohibited exception. Substituted types: no_tests_bug.NoTestsProblem, builtins.str, builtins.list[typing.Any], builtins.list[typing.Any]. Exception type: builtins.TypeError
2023-02-17 16:44:30,154 [6034483]   INFO - STDOUT - | UtBot - PythonEngine              | Evaluation with prohibited exception. Substituted types: no_tests_bug.NoTestsProblem, builtins.str, builtins.list[typing.Any], builtins.list[typing.Any]. Exception type: builtins.TypeError
2023-02-17 16:44:30,374 [6034703]   INFO - STDOUT - | UtBot - PythonEngine              | Evaluation with prohibited exception. Substituted types: no_tests_bug.NoTestsProblem, builtins.str, builtins.list[typing.Any], builtins.list[typing.Any]. Exception type: builtins.TypeError

Metadata

Metadata

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a buglang-pythonIssue is related to python support

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions