Skip to content

test: add boundary tests for text(max_nb_chars) - #2439

Open
saimoon504 wants to merge 1 commit into
joke2k:masterfrom
saimoon504:test/text-max-nb-chars-bounds
Open

test: add boundary tests for text(max_nb_chars)#2439
saimoon504 wants to merge 1 commit into
joke2k:masterfrom
saimoon504:test/text-max-nb-chars-bounds

Conversation

@saimoon504

Copy link
Copy Markdown

Related to #2389

Brief summary: adds three tests to tests/providers/test_lorem.py
pinning down the boundary behavior of text(max_nb_chars).

What was wrong

The existing lorem tests exercise text() per locale but do not test
its boundary behavior. While testing Faker for a university course we
noticed this gap when investigating #2389.

How this fixes it

Adds a TestTextBounds class with three tests:

  • test_text_respects_upper_bound - output never exceeds max_nb_chars,
    checked around the internal mode switches at 25 and 100 characters
  • test_text_minimum_length_raises - values below 5 raise ValueError
    (enforced in the code but previously untested)
  • test_text_ext_word_list_only - with ext_word_list, every word in the
    output comes from the given list

All three pass locally: 3 passed in 0.67s on Python 3.10.12.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant