| 1 |
from string import ascii_letters as letters, digits, punctuation |
| 2 |
|
| 3 |
from graphql.language.character_classes import ( |
| 4 |
is_digit, |
| 5 |
is_letter, |
| 6 |
is_name_start, |
| 7 |
is_name_continue, |
| 8 |
) |
| 9 |
|
| 10 |
non_ascii = "¯_±¹²³½£ºµÄäÖöØø×〇᧐〸αΑωΩ" |
| 11 |
|
| 12 |
|
| 13 |
def describe_digit(): |
| 14 |
def accepts_digits(): |
| 15 |
assert all(is_digit(char) for char in digits) |
| 16 |
|
| 17 |
def rejects_letters(): |
| 18 |
assert not any(is_digit(char) for char in letters) |
| 19 |
|
| 20 |
def rejects_underscore(): |
| 21 |
assert not is_digit("_") |
| 22 |
|
| 23 |
def rejects_punctuation(): |
| 24 |
assert not any(is_digit(char) for char in punctuation) |
| 25 |
|
| 26 |
def rejects_non_ascii(): |
| 27 |
assert not any(is_digit(char) for char in non_ascii) |
| 28 |
|
| 29 |
def rejects_empty_string(): |
| 30 |
assert not is_digit("") |
| 31 |
|
| 32 |
|
| 33 |
def describe_letter(): |
| 34 |
def accepts_letters(): |
| 35 |
assert all(is_letter(char) for char in letters) |
| 36 |
|
| 37 |
def rejects_digits(): |
| 38 |
assert not any(is_letter(char) for char in digits) |
| 39 |
|
| 40 |
def rejects_underscore(): |
| 41 |
assert not is_letter("_") |
| 42 |
|
| 43 |
def rejects_punctuation(): |
| 44 |
assert not any(is_letter(char) for char in punctuation) |
| 45 |
|
| 46 |
def rejects_non_ascii(): |
| 47 |
assert not any(is_letter(char) for char in non_ascii) |
| 48 |
|
| 49 |
def rejects_empty_string(): |
| 50 |
assert not is_letter("") |
| 51 |
|
| 52 |
|
| 53 |
def describe_name_start(): |
| 54 |
def accepts_letters(): |
| 55 |
assert all(is_name_start(char) for char in letters) |
| 56 |
|
| 57 |
def accepts_underscore(): |
| 58 |
assert is_name_start("_") |
| 59 |
|
| 60 |
def rejects_digits(): |
| 61 |
assert not any(is_name_start(char) for char in digits) |
| 62 |
|
| 63 |
def rejects_punctuation(): |
| 64 |
assert not any(is_name_start(char) for char in punctuation if char != "_") |
| 65 |
|
| 66 |
def rejects_non_ascii(): |
| 67 |
assert not any(is_name_start(char) for char in non_ascii) |
| 68 |
|
| 69 |
def rejects_empty_string(): |
| 70 |
assert not is_name_start("") |
| 71 |
|
| 72 |
|
| 73 |
def describe_name_continue(): |
| 74 |
def accepts_letters(): |
| 75 |
assert all(is_name_continue(char) for char in letters) |
| 76 |
|
| 77 |
def accepts_digits(): |
| 78 |
assert all(is_name_continue(char) for char in digits) |
| 79 |
|
| 80 |
def accepts_underscore(): |
| 81 |
assert is_name_continue("_") |
| 82 |
|
| 83 |
def rejects_punctuation(): |
| 84 |
assert not any(is_name_continue(char) for char in punctuation if char != "_") |
| 85 |
|
| 86 |
def rejects_non_ascii(): |
| 87 |
assert not any(is_name_continue(char) for char in non_ascii) |
| 88 |
|
| 89 |
def rejects_empty_string(): |
| 90 |
assert not is_name_continue("") |