Skip to content

Too many similar test in langchain project for get_color_mapping function #1945

Closed
@tyuldashev

Description

@tyuldashev

Description

For some reason UTbot Python generates many very similar tests for one function.

To Reproduce

Steps to reproduce the behavior:

  1. Clone langchain project - https://github.com/hwchase17/langchain
  2. Open langchain/input.py file
  3. Generate tests for get_color_mapping function with default settings

Expected behavior

Some tests are supposed to be generated.

Actual behavior

According to comment UTBot generates hundreds or thousands of very similar tests. Fortunately they are limited by maxTestsPerMethod setting. Even though this improves path coverage it doesn't look practically useful. Could we improve it or that's by design?

Here is couple of such test:

    # Actual number of generated tests (2588) exceeds per-method limit (50)
    # The limit can be configured in '{HOME_DIR}/.utbot/settings.properties' with 'maxTestsPerMethod' property

    def test_get_color_mapping2(self):
        """
        items = builtins.list[builtins.str]
        """
        actual = langchain.input.get_color_mapping(['Get mapping for items to a support color.', '€', 'pythön', 'foo'])
        
        self.assertEqual({'Get mapping for items to a support color.': 'blue', '€': 'yellow', 'pythön': 'pink', 'foo': 'green', }, actual)
    
    def test_get_color_mapping3(self):
        """
        items = builtins.list[builtins.str]
        """
        actual = langchain.input.get_color_mapping(['abcdefghijklmnopqrst', 'Get mapping for items to a support color.'])
        
        self.assertEqual({'abcdefghijklmnopqrst': 'blue', 'Get mapping for items to a support color.': 'yellow', }, actual)

Additional context

For some reason it's reproducible only inside the project. If I copy/paste the same file into separate project it generates just couple tests as I would expect.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions