Skip to content

Random-name test can fail on valid duplicate draws #722

Closed

Description

Problem

tests/components/util/test_name_generator.py::test_generate_name_generates_names_randomly asserts that two unseeded random names differ. Duplicate draws are valid, so the assertion intermittently fails an otherwise passing suite.

Evidence

A full Python 3.11 test run failed with:

assert 'Dancing Magenta Caribou' != 'Dancing Magenta Caribou'
1 failed, 2806 passed, 81 skipped

The isolated name-generator tests passed on rerun. Neither the test nor NameGenerator differed from master commit f3deb21.

A deterministic reproduction on Python 3.11 is:

import random
from lean.components.util.name_generator import NameGenerator

random.seed(11986)
generator = NameGenerator()
first = generator.generate_name()
second = generator.generate_name()
print(first, second)
assert first != second

Both calls return Creative Sky Blue Armadillo, and the assertion fails. generate_name independently selects a verb, color and animal; it does not promise uniqueness.

Expected behavior

The test should check the intended use of randomness without depending on two independent draws being different. Suggestion: control the choices or random state in the test and assert the expected sequence. No production uniqueness guarantee is needed for this test-only fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions