コード例 #1
0
ファイル: tests.py プロジェクト: NinaKumpss/Exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_valid_email_address') as (match, no_match):
    match('*****@*****.**')
    match('*****@*****.**')
    match('*****@*****.**')
    match('*****@*****.**')
    match('*****@*****.**')

    no_match('')
    no_match('a')
    no_match('*****@*****.**')
    no_match('*****@*****.**')
    no_match('*****@*****.**')
    no_match('@ucll.be')
    no_match('a.b@')
    no_match('xucll.be')
    no_match('a.b@ucllxbe')
    no_match('a.b@studentxucllxbe')
    no_match('*****@*****.**')
    no_match('*****@*****.**')
コード例 #2
0
ファイル: tests.py プロジェクト: stuke82/scripting-exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('twice_repeated') as (match, no_match):
    match('aa')
    match('xx')
    match('11')
    match('..')

    no_match('')
    no_match('a')
    no_match('aaa')
    no_match('aab')
    no_match('aaax')
    no_match('xaaa')
コード例 #3
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('one_or_more_b') as (match, no_match):
    match('b')
    match('bb')
    match('bbb')
    match('bbbb')
    match('bbbbb')

    no_match('')
    no_match('a')
    no_match('ab')
    no_match('aab')
    no_match('ba')
コード例 #4
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey


with regex_test('ababa') as (match, no_match):
    match('ababa')
    match('xyxyx')
    match('12121')
    match('aabbaabbaa')
    match('111222111222111')
    match('.xxx.xxx.')
    match('...x...x...')

    no_match('')
    no_match('aaa')
    no_match('aba')
    no_match('abab')
    no_match('baba')
    no_match('12x12y12')
    no_match('abaca')
    no_match('1x2x3')
コード例 #5
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey


with regex_test('abc_or_xyz') as (match, no_match):
    match('abc')
    match('xyz')

    no_match('')
    no_match('a')
    no_match('ab')
    no_match('abca')
    no_match('x')
    no_match('xy')
    no_match('xyza')
    no_match('abcxyz')
コード例 #6
0
ファイル: tests.py プロジェクト: NinaKumpss/Exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_valid_time') as (match, no_match):
    match('00:00:00')
    match('00:00:00.000')
    match('12:34:56.789')

    no_match('')
    no_match('0:00:00')
    no_match('00:0:00')
    no_match('00:00:0')
    no_match('00:00:00:000')
    no_match('aa:aa:aa')
コード例 #7
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_valid_password') as (match, _no_match):

    def no_match(string, reason):
        _no_match(string, f"'{string}' should be rejected: {reason}")

    match('aA1+oipa')
    match('7Af9xf*6')
    match('Fpq75s.4+')

    no_match('aA1+', 'too short')
    no_match('aA1+fqx', 'too short')
    no_match('a19+fqios', 'does not contain an uppercase letter')
    no_match('-13AG1PA', 'does not contain a lowercase letter')
    no_match('aOO+fqios', 'does not contain a digit')
    no_match('aOO9fq5os', 'does not contain special symbol')
    no_match('aaa12+Fk', 'three consecutive times a')
    no_match('Lf8xxx12+Fk', 'three consecutive times x')
    no_match('A.A7AaA', 'four times A')
コード例 #8
0
ファイル: tests.py プロジェクト: stuke82/scripting-exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('two_or_more_abc') as (match, no_match):
    match('abcabc')
    match('abcabcabc')
    match('abcabcabcabc')

    no_match('')
    no_match('a')
    no_match('ab')
    no_match('abc')
    no_match('abcabcab')
    no_match('bcabca')
コード例 #9
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('starts_with_a') as (match, no_match):
    match('a')
    match('ab')
    match('aaaa')
    match('ax')

    no_match('')
    no_match('b')
    no_match('ga')
    no_match('xxaa')
コード例 #10
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('equals_a') as (match, no_match):
    match('a')

    no_match('b')
    no_match('')
    no_match('aa')
コード例 #11
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey


with regex_test('only_digits') as (match, no_match):
    match('')
    match('0')
    match('1')
    match('2')
    match('3')
    match('4')
    match('5')
    match('6')
    match('7')
    match('8')
    match('9')
    match('1235020284')

    no_match('a')
    no_match('d')
    no_match('125f')
    no_match('78a3')
    no_match('q2100')
コード例 #12
0
ファイル: tests.py プロジェクト: stuke82/scripting-exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_number') as (match, no_match):
    match('0')
    match('1')
    match('2')
    match('3')
    match('4')
    match('5')
    match('6')
    match('7')
    match('8')
    match('9')
    match('0.1')
    match('3.141592')
    match('1980')

    no_match('')
    no_match('.')
    no_match('.0')
    no_match('0.')
    no_match('b')
    no_match('1.2.3')
    no_match('1,2')
コード例 #13
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_valid_student_id') as (match, no_match):
    match('r1234567')
    match('R1234567')
    match('s1234567')
    match('S1234567')
    match('r0000000')

    no_match('t1234567')
    no_match('1234567')
    no_match('r134567')
    no_match('r12345678')
    no_match('xr1234567')
    no_match('r1234567x')
コード例 #14
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('ten_times_abc') as (match, no_match):
    match('abc' * 10)

    no_match('')
    no_match('a')
    no_match('ab')
    no_match('abc')
    no_match('abc' * 9)
    no_match('abc' * 11)
    no_match('abc' * 12)
    no_match('abc' * 13)
    no_match('abc' * 14)
コード例 #15
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('contains_no_a') as (match, no_match):
    match('')
    match('x')
    match('bqopvpod')

    no_match('a')
    no_match('xxxaxxxx')
    no_match('pppa')
コード例 #16
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('only_letters') as (match, no_match):
    match('')
    match('a')
    match('P')
    match('fPczLO')

    no_match('7')
    no_match('d5')
    no_match('4012f78')
コード例 #17
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('is_dna') as (match, no_match):
    match('')
    match('G')
    match('A')
    match('T')
    match('C')
    match('CGAT')
    match('GCCTATAGTAGACG')
    match('CCCCGGGGAAAATTTT')

    no_match('a')
    no_match('g')
    no_match('c')
    no_match('t')
    no_match('q')
    no_match('Q')
    no_match('PGATCCCC')
コード例 #18
0
ファイル: tests.py プロジェクト: ThomasCl/exercises
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('only_vowels') as (match, no_match):
    match('')
    match('a')
    match('e')
    match('i')
    match('o')
    match('u')
    match('aeiou')
    match('eioaauie')

    no_match('x')
    no_match('ab')
    no_match('aiop')
    no_match('xooo')
コード例 #19
0
from contextlib import contextmanager
from scripting.testing import test
from scripting.quick import regex_test
from scripting.assertions import assert_truthy, assert_falsey

with regex_test('contains_three_digits') as (match, no_match):
    match('123')
    match('8132')
    match('a813')
    match('813x')
    match('g813x')
    match('9x9x9')
    match('f8a1q3x')
    match('dddd787ddddd')

    no_match('')
    no_match('5')
    no_match('12')
    no_match('5q9f')