slavos1 / pytest-bdd-html

pytest plugin to display BDD info in HTML test report
MIT License
3 stars 0 forks source link

Remove faker #1

Open slavos1 opened 2 years ago

slavos1 commented 2 years ago

We use it only for generating a simple sentence; can use alphanums sequence chosen by secrets.choice instead.

slavos1 commented 2 years ago

A nice example in Python doc -- works on Linux (Ubuntu):

# On standard Linux systems, use a convenient dictionary file.
# Other platforms may need to provide their own word-list.
with open('/usr/share/dict/words') as f:
    words = [word.strip() for word in f]
    password = ' '.join(choice(words) for i in range(4))

In case the file does not exist, we can fallback to something like:

import string
alphabet = string.ascii_letters + string.digits
password = ''.join(choice(alphabet) for i in range(8))
slavos1 commented 1 year ago

Or it can just be always random text of some hard-coded length, say:

@pytest.fixture
def description():
    alphabet = string.ascii_letters + string.digits
    return ' '.join(''.join(choice(alphabet) for _ in range(num_chars)) for _ in range(num_words))