new API
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 2s

This commit is contained in:
2026-04-13 23:02:57 +02:00
parent a44248bc50
commit 4d115e3de4
17 changed files with 965 additions and 275 deletions

View File

@@ -5,7 +5,7 @@ import kpmatch
class MatchTests(TestCase):
def test_match_empty(self):
pattern = kpmatch.compile("")
(pattern,) = kpmatch.compile("")
self.assertTrue(pattern.match(""))
self.assertFalse(pattern.match("index.html"))
self.assertFalse(pattern.match("about"))
@@ -13,7 +13,7 @@ class MatchTests(TestCase):
self.assertFalse(pattern.match("content/deep/deeper/file.txt"))
def test_match_any(self):
pattern = kpmatch.compile("**")
(pattern,) = kpmatch.compile("**")
self.assertTrue(pattern.match(""))
self.assertTrue(pattern.match("index.html"))
self.assertTrue(pattern.match("about"))
@@ -21,7 +21,7 @@ class MatchTests(TestCase):
self.assertTrue(pattern.match("content/deep/deeper/file.txt"))
def test_match_any_name(self):
pattern = kpmatch.compile("*.html")
(pattern,) = kpmatch.compile("*.html")
self.assertTrue(pattern.match("index.html"))
self.assertTrue(pattern.match("about.html"))
self.assertFalse(pattern.match("about"))
@@ -29,7 +29,7 @@ class MatchTests(TestCase):
self.assertFalse(pattern.match("content/deep/deeper/file.txt"))
def test_match_any_name_anywhere(self):
pattern = kpmatch.compile("**/*.html")
(pattern,) = kpmatch.compile("**/*.html")
self.assertTrue(pattern.match("index.html"))
self.assertTrue(pattern.match("about.html"))
self.assertFalse(pattern.match("about"))
@@ -38,36 +38,28 @@ class MatchTests(TestCase):
self.assertFalse(pattern.match("content/deep/deeper/file.txt"))
def test_match_any_directory_name(self):
pattern = kpmatch.compile("packages/*/package.json")
(pattern,) = kpmatch.compile("packages/*/package.json")
self.assertFalse(pattern.match("packages/package.json"))
self.assertTrue(pattern.match("packages/a/package.json"))
self.assertTrue(pattern.match("packages/b/package.json"))
self.assertFalse(pattern.match("packages/a/b/package.json"))
def test_match_one_of(self):
pattern = kpmatch.compile("*.{png,jpg,jpeg,webp}")
self.assertTrue(pattern.match("image.png"))
self.assertTrue(pattern.match("image.jpg"))
self.assertTrue(pattern.match("image.jpeg"))
self.assertTrue(pattern.match("image.webp"))
self.assertFalse(pattern.match("image.svg"))
def test_match_character_set(self):
pattern = kpmatch.compile("*.[jt]s")
(pattern,) = kpmatch.compile("*.[jt]s")
self.assertTrue(pattern.match("file.js"))
self.assertTrue(pattern.match("file.ts"))
self.assertFalse(pattern.match("file.rs"))
self.assertFalse(pattern.match("file.cs"))
def test_match_negative_character_set(self):
pattern = kpmatch.compile("*.[!jt]s")
(pattern,) = kpmatch.compile("*.[!jt]s")
self.assertFalse(pattern.match("file.js"))
self.assertFalse(pattern.match("file.ts"))
self.assertTrue(pattern.match("file.rs"))
self.assertTrue(pattern.match("file.cs"))
def test_match_any_character(self):
pattern = kpmatch.compile("*.?s")
(pattern,) = kpmatch.compile("*.?s")
self.assertTrue(pattern.match("file.js"))
self.assertTrue(pattern.match("file.ts"))
self.assertTrue(pattern.match("file.rs"))