aboutsummaryrefslogtreecommitdiff
path: root/tests/pattern/classes.test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pattern/classes.test.py')
-rw-r--r--tests/pattern/classes.test.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/pattern/classes.test.py b/tests/pattern/classes.test.py
new file mode 100644
index 0000000..de6bfc0
--- /dev/null
+++ b/tests/pattern/classes.test.py
@@ -0,0 +1,58 @@
+"""Tests for the module-level character-class :class:`Pattern` constants."""
+
+import pytest
+
+from edify import (
+ ANY_CHAR,
+ CARRIAGE_RETURN,
+ DIGIT,
+ NEW_LINE,
+ NON_DIGIT,
+ NON_WHITESPACE,
+ NON_WORD,
+ NULL_BYTE,
+ TAB,
+ WHITESPACE,
+ WORD,
+ Pattern,
+)
+
+
+ ("constant", "expected"),
+ [
+ (ANY_CHAR, "."),
+ (WHITESPACE, "\\s"),
+ (NON_WHITESPACE, "\\S"),
+ (DIGIT, "\\d"),
+ (NON_DIGIT, "\\D"),
+ (WORD, "\\w"),
+ (NON_WORD, "\\W"),
+ (NEW_LINE, "\\n"),
+ (CARRIAGE_RETURN, "\\r"),
+ (TAB, "\\t"),
+ (NULL_BYTE, "\\0"),
+ ],
+)
+def test_character_class_constant_compiles_to_expected_regex(constant, expected):
+ assert constant.to_regex_string() == expected
+
+
+ "constant",
+ [
+ ANY_CHAR,
+ WHITESPACE,
+ NON_WHITESPACE,
+ DIGIT,
+ NON_DIGIT,
+ WORD,
+ NON_WORD,
+ NEW_LINE,
+ CARRIAGE_RETURN,
+ TAB,
+ NULL_BYTE,
+ ],
+)
+def test_character_class_constant_is_a_pattern(constant):
+ assert isinstance(constant, Pattern)