4 from szyfrow
.support
.utilities
import *
7 for n
, l
in enumerate(string
.ascii_lowercase
):
9 for n
, l
in enumerate(string
.ascii_uppercase
):
11 with pytest
.raises(ValueError):
15 for n
, l
in enumerate(string
.ascii_lowercase
):
17 assert l
== unpos(n
+ 26)
18 for n
, l
in enumerate(string
.ascii_uppercase
):
19 assert l
.lower() == unpos(n
)
20 with pytest
.raises(ValueError):
24 assert pad(10, 3, '*') == '**'
25 assert pad(10, 5, '*') == ''
26 assert pad(10, 3, lambda: '!') == '!!'
29 assert every_nth(string
.ascii_lowercase
, 5) == ['afkpuz', 'bglqv', 'chmrw', 'dinsx', 'ejoty']
30 assert every_nth(string
.ascii_lowercase
, 1) == ['abcdefghijklmnopqrstuvwxyz']
31 assert every_nth(string
.ascii_lowercase
, 26) == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
32 assert every_nth(string
.ascii_lowercase
, 5, fillvalue
='!') == ['afkpuz', 'bglqv!', 'chmrw!', 'dinsx!', 'ejoty!']
34 def test_combine_every_nth():
35 for i
in range(1, 27):
36 assert combine_every_nth(every_nth(string
.ascii_lowercase
, 5)) == string
.ascii_lowercase
39 def test_chunks_on_text():
40 assert chunks('abcdefghi', 3) == ['abc', 'def', 'ghi']
41 assert chunks('abcdefghi', 4) == ['abcd', 'efgh', 'i']
42 assert chunks('abcdefghi', 4, fillvalue
='!') == ['abcd', 'efgh', 'i!!!']
44 def test_chunks_on_nontext():
45 ns
= [1,2,3,4,5,6,7,8,9]
46 assert chunks(ns
, 3) == [[1,2,3],[4,5,6],[7,8,9]]
49 assert transpose(['a', 'b', 'c', 'd'], (0,1,2,3)) == ['a', 'b', 'c', 'd']
50 assert transpose(['a', 'b', 'c', 'd'], (3,1,2,0)) == ['d', 'b', 'c', 'a']
51 assert transpose([10,11,12,13,14,15], (3,2,4,1,5,0)) == [13, 12, 14, 11, 15, 10]
53 def test_untranspose():
54 assert untranspose(['a', 'b', 'c', 'd'], [0,1,2,3]) == ['a', 'b', 'c', 'd']
55 assert untranspose(['d', 'b', 'c', 'a'], [3,1,2,0]) == ['a', 'b', 'c', 'd']
56 assert untranspose([13, 12, 14, 11, 15, 10], [3,2,4,1,5,0]) == [10, 11, 12, 13, 14, 15]
59 assert letters('The Quick') == 'TheQuick'
60 assert letters('The Quick BROWN fox jumped! over... the (9lazy) DOG') == 'TheQuickBROWNfoxjumpedoverthelazyDOG'
63 assert unaccent('hello') == 'hello'
64 assert unaccent('HELLO') == 'HELLO'
65 assert unaccent('héllo') == 'hello'
66 assert unaccent('héllö') == 'hello'
67 assert unaccent('HÉLLÖ') == 'HELLO'
70 assert sanitise('The Quick') == 'thequick'
71 assert sanitise('The Quick BROWN fox jumped! over... the (9lazy) DOG') == 'thequickbrownfoxjumpedoverthelazydog'
72 assert sanitise('HÉLLÖ') == 'hello'