Source

House Password - python coding challenges - Py.CheckiO

My solution

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest

from re import search


def validate(mystr):
    '''
    Validate `mystr`.
    
    Return True if the ASCII latin string `mystr` contains at least 10
    characters, including at least one digit, at least one uppercase
    letter, and one lowercase letter.
    '''
    return len(mystr) >= 10 and \
        bool(search('[0-9]', mystr)) and \
        bool(search('[a-z]', mystr)) and \
        bool(search('[A-Z]', mystr))


def test_mytest():
    assert not validate('')
    assert not validate('a')


def test_provided():
    assert not validate('A1213pokl')
    assert validate('bAse730onE')
    assert not validate('asasasasasasasaas')
    assert not validate('QWERTYqwerty')
    assert not validate('123456123456')
    assert validate('QwErTy911poqqqq')


pytest.main([__file__])