-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathtest_character_classes.py
91 lines (61 loc) · 2.37 KB
/
test_character_classes.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from string import ascii_letters as letters
from string import digits, punctuation
from graphql.language.character_classes import (
is_digit,
is_letter,
is_name_continue,
is_name_start,
)
non_ascii = "¯_±¹²³½£ºµÄäÖöØø×〇᧐〸αΑωΩ" # noqa: RUF001
def describe_digit():
def accepts_digits():
assert all(is_digit(char) for char in digits)
def rejects_letters():
assert not any(is_digit(char) for char in letters)
def rejects_underscore():
assert not is_digit("_")
def rejects_punctuation():
assert not any(is_digit(char) for char in punctuation)
def rejects_non_ascii():
assert not any(is_digit(char) for char in non_ascii)
def rejects_empty_string():
assert not is_digit("")
def describe_letter():
def accepts_letters():
assert all(is_letter(char) for char in letters)
def rejects_digits():
assert not any(is_letter(char) for char in digits)
def rejects_underscore():
assert not is_letter("_")
def rejects_punctuation():
assert not any(is_letter(char) for char in punctuation)
def rejects_non_ascii():
assert not any(is_letter(char) for char in non_ascii)
def rejects_empty_string():
assert not is_letter("")
def describe_name_start():
def accepts_letters():
assert all(is_name_start(char) for char in letters)
def accepts_underscore():
assert is_name_start("_")
def rejects_digits():
assert not any(is_name_start(char) for char in digits)
def rejects_punctuation():
assert not any(is_name_start(char) for char in punctuation if char != "_")
def rejects_non_ascii():
assert not any(is_name_start(char) for char in non_ascii)
def rejects_empty_string():
assert not is_name_start("")
def describe_name_continue():
def accepts_letters():
assert all(is_name_continue(char) for char in letters)
def accepts_digits():
assert all(is_name_continue(char) for char in digits)
def accepts_underscore():
assert is_name_continue("_")
def rejects_punctuation():
assert not any(is_name_continue(char) for char in punctuation if char != "_")
def rejects_non_ascii():
assert not any(is_name_continue(char) for char in non_ascii)
def rejects_empty_string():
assert not is_name_continue("")