コード例 #1
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_04_infix_wildcard(self):
        """
		Tests a pattern with an infix wildcard.

		This should match:

			foo--bar
			foo-hello-bar
			a/foo-hello-bar
			foo-hello-bar/b
			a/foo-hello-bar/b
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("foo-*-bar")
        self.assertTrue(include)
        self.assertEqual(regex, "^(?:.+/)?foo\\-[^/]*\\-bar(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "foo--bar",
                "foo-hello-bar",
                "a/foo-hello-bar",
                "foo-hello-bar/b",
                "a/foo-hello-bar/b",
            ]))
        self.assertEqual(
            results,
            {
                "foo--bar",
                "foo-hello-bar",
                "a/foo-hello-bar",
                "foo-hello-bar/b",
                "a/foo-hello-bar/b",
            },
        )
コード例 #2
0
	def test_04_postfix_wildcard(self):
		"""
		Tests a pattern with a postfix wildcard.

		This should match:

			~temp-
			~temp-foo
			~temp-foo/bar
			foo/~temp-bar
			foo/~temp-bar/baz
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('~temp-*')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?\\~temp\\-[^/]*(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'~temp-',
			'~temp-foo',
			'~temp-foo/bar',
			'foo/~temp-bar',
			'foo/~temp-bar/baz',
		]))
		self.assertEqual(results, {
			'~temp-',
			'~temp-foo',
			'~temp-foo/bar',
			'foo/~temp-bar',
			'foo/~temp-bar/baz',
		})
コード例 #3
0
	def test_07_match_bytes_and_unicode(self):
		"""
		Test byte string patterns matching byte string paths.
		"""
		pattern = GitWildMatchPattern(b'*.py')
		results = set(pattern.match(['a.py']))
		self.assertEqual(results, {'a.py'})
コード例 #4
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_03_inner_double_asterisk(self):
        """
		Tests a path with an inner double-asterisk directory.

		This should match:

			left/bar/right
			left/foo/bar/right
			left/bar/right/foo

		This should **not** match (according to git check-ignore (v2.4.1)):

			foo/left/bar/right
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("left/**/right")
        self.assertTrue(include)
        self.assertEqual(regex, "^left(?:/.+)?/right(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "left/bar/right",
                "left/foo/bar/right",
                "left/bar/right/foo",
                "foo/left/bar/right",
            ]))
        self.assertEqual(results, {
            "left/bar/right",
            "left/foo/bar/right",
            "left/bar/right/foo",
        })
コード例 #5
0
	def test_04_prefix_wildcard(self):
		"""
		Tests a pattern with a prefix wildcard.

		This should match:

			bar.py
			bar.py/
			foo/bar.py
			foo/bar.py/baz
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('*.py')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?[^/]*\\.py(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'bar.py',
			'bar.py/',
			'foo/bar.py',
			'foo/bar.py/baz',
		]))
		self.assertEqual(results, set([
			'bar.py',
			'bar.py/',
			'foo/bar.py',
			'foo/bar.py/baz',
		]))
コード例 #6
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_01_relative_nested(self):
        """
		Tests a relative nested path pattern.

		This should match:

			foo/spam
			foo/spam/bar

		This should **not** match (according to git check-ignore (v2.4.1)):

			bar/foo/spam
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("foo/spam")
        self.assertTrue(include)
        self.assertEqual(regex, "^foo/spam(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "foo/spam",
                "foo/spam/bar",
                "bar/foo/spam",
            ]))
        self.assertEqual(results, {
            "foo/spam",
            "foo/spam/bar",
        })
コード例 #7
0
	def test_07_match_unicode_and_unicode(self):
		"""
		Test unicode patterns with unicode paths.
		"""
		pattern = GitWildMatchPattern('*.py')
		results = set(pattern.match(['a.py']))
		self.assertEqual(results, {'a.py'})
コード例 #8
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_05_directory(self):
        """
		Tests a directory pattern.

		This should match:

			dir/
			foo/dir/
			foo/dir/bar

		This should **not** match:

			dir
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("dir/")
        self.assertTrue(include)
        self.assertEqual(regex, "^(?:.+/)?dir/.*$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "dir/",
                "foo/dir/",
                "foo/dir/bar",
                "dir",
            ]))
        self.assertEqual(results, {
            "dir/",
            "foo/dir/",
            "foo/dir/bar",
        })
コード例 #9
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_05_directory(self):
		"""
		Tests a directory pattern.

		This should match:

			dir/
			foo/dir/
			foo/dir/bar

		This should **not** match:

			dir
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('dir/')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?dir/.*$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'dir/',
			'foo/dir/',
			'foo/dir/bar',
			'dir',
		]))
		self.assertEqual(results, {
			'dir/',
			'foo/dir/',
			'foo/dir/bar',
		})
コード例 #10
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_07_match_bytes_and_bytes(self):
		"""
		Test byte string patterns matching byte string paths.
		"""
		pattern = GitWildMatchPattern(b'*.py')
		results = set(pattern.match([b'a.py']))
		self.assertEqual(results, {b'a.py'})
コード例 #11
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_04_postfix_wildcard(self):
		"""
		Tests a pattern with a postfix wildcard.

		This should match:

			~temp-
			~temp-foo
			~temp-foo/bar
			foo/~temp-bar
			foo/~temp-bar/baz
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('~temp-*')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?\\~temp\\-[^/]*(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'~temp-',
			'~temp-foo',
			'~temp-foo/bar',
			'foo/~temp-bar',
			'foo/~temp-bar/baz',
		]))
		self.assertEqual(results, {
			'~temp-',
			'~temp-foo',
			'~temp-foo/bar',
			'foo/~temp-bar',
			'foo/~temp-bar/baz',
		})
コード例 #12
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_03_parent_double_asterisk(self):
		"""
		Tests a file name with a double-asterisk parent directory.

		This should match:

			spam
			foo/spam
			foo/spam/bar
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('**/spam')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?spam(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'spam',
			'foo/spam',
			'foo/spam/bar',
		]))
		self.assertEqual(results, {
			'spam',
			'foo/spam',
			'foo/spam/bar',
		})
コード例 #13
0
	def test_01_absolute(self):
		"""
		Tests an absolute path pattern.

		This should match:

			an/absolute/file/path
			an/absolute/file/path/foo

		This should NOT match:

			foo/an/absolute/file/path
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('/an/absolute/file/path')
		self.assertTrue(include)
		self.assertEqual(regex, '^an/absolute/file/path(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'an/absolute/file/path',
			'an/absolute/file/path/foo',
			'foo/an/absolute/file/path',
		]))
		self.assertEqual(results, set([
			'an/absolute/file/path',
			'an/absolute/file/path/foo',
		]))
コード例 #14
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_01_absolute(self):
        """
		Tests an absolute path pattern.

		This should match:

			an/absolute/file/path
			an/absolute/file/path/foo

		This should NOT match:

			foo/an/absolute/file/path
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex(
            "/an/absolute/file/path")
        self.assertTrue(include)
        self.assertEqual(regex, "^an/absolute/file/path(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "an/absolute/file/path",
                "an/absolute/file/path/foo",
                "foo/an/absolute/file/path",
            ]))
        self.assertEqual(results, {
            "an/absolute/file/path",
            "an/absolute/file/path/foo",
        })
コード例 #15
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_07_match_unicode_and_bytes(self):
		"""
		Test unicode patterns with byte paths.
		"""
		pattern = GitWildMatchPattern('*.py')
		results = set(pattern.match([b'a.py']))
		self.assertEqual(results, {b'a.py'})
コード例 #16
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_04_prefix_wildcard(self):
        """
		Tests a pattern with a prefix wildcard.

		This should match:

			bar.py
			bar.py/
			foo/bar.py
			foo/bar.py/baz
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("*.py")
        self.assertTrue(include)
        self.assertEqual(regex, "^(?:.+/)?[^/]*\\.py(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "bar.py",
                "bar.py/",
                "foo/bar.py",
                "foo/bar.py/baz",
            ]))
        self.assertEqual(results, {
            "bar.py",
            "bar.py/",
            "foo/bar.py",
            "foo/bar.py/baz",
        })
コード例 #17
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_01_relative(self):
		"""
		Tests a relative path pattern.

		This should match:

			spam
			spam/
			foo/spam
			spam/foo
			foo/spam/bar
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('spam')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?spam(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'spam',
			'spam/',
			'foo/spam',
			'spam/foo',
			'foo/spam/bar',
		]))
		self.assertEqual(results, {
			'spam',
			'spam/',
			'foo/spam',
			'spam/foo',
			'foo/spam/bar',
		})
コード例 #18
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_07_match_bytes_and_unicode(self):
        """
		Test byte string patterns matching byte string paths.
		"""
        pattern = GitWildMatchPattern(b"*.py")
        results = set(pattern.match(["a.py"]))
        self.assertEqual(results, {"a.py"})
コード例 #19
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_04_postfix_wildcard(self):
        """
		Tests a pattern with a postfix wildcard.

		This should match:

			~temp-
			~temp-foo
			~temp-foo/bar
			foo/~temp-bar
			foo/~temp-bar/baz
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("~temp-*")
        self.assertTrue(include)
        self.assertEqual(regex, "^(?:.+/)?\\~temp\\-[^/]*(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "~temp-",
                "~temp-foo",
                "~temp-foo/bar",
                "foo/~temp-bar",
                "foo/~temp-bar/baz",
            ]))
        self.assertEqual(
            results,
            {
                "~temp-",
                "~temp-foo",
                "~temp-foo/bar",
                "foo/~temp-bar",
                "foo/~temp-bar/baz",
            },
        )
コード例 #20
0
	def test_04_infix_wildcard(self):
		"""
		Tests a pattern with an infix wildcard.

		This should match:

			foo--bar
			foo-hello-bar
			a/foo-hello-bar
			foo-hello-bar/b
			a/foo-hello-bar/b
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('foo-*-bar')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?foo\\-[^/]*\\-bar(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'foo--bar',
			'foo-hello-bar',
			'a/foo-hello-bar',
			'foo-hello-bar/b',
			'a/foo-hello-bar/b',
		]))
		self.assertEqual(results, {
			'foo--bar',
			'foo-hello-bar',
			'a/foo-hello-bar',
			'foo-hello-bar/b',
			'a/foo-hello-bar/b',
		})
コード例 #21
0
	def test_04_prefix_wildcard(self):
		"""
		Tests a pattern with a prefix wildcard.

		This should match:

			bar.py
			bar.py/
			foo/bar.py
			foo/bar.py/baz
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('*.py')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?[^/]*\\.py(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'bar.py',
			'bar.py/',
			'foo/bar.py',
			'foo/bar.py/baz',
		]))
		self.assertEqual(results, {
			'bar.py',
			'bar.py/',
			'foo/bar.py',
			'foo/bar.py/baz',
		})
コード例 #22
0
	def test_01_relative(self):
		"""
		Tests a relative path pattern.

		This should match:

			spam
			spam/
			foo/spam
			spam/foo
			foo/spam/bar
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('spam')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?spam(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'spam',
			'spam/',
			'foo/spam',
			'spam/foo',
			'foo/spam/bar',
		]))
		self.assertEqual(results, {
			'spam',
			'spam/',
			'foo/spam',
			'spam/foo',
			'foo/spam/bar',
		})
コード例 #23
0
	def test_01_absolute(self):
		"""
		Tests an absolute path pattern.

		This should match:

			an/absolute/file/path
			an/absolute/file/path/foo

		This should NOT match:

			foo/an/absolute/file/path
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('/an/absolute/file/path')
		self.assertTrue(include)
		self.assertEqual(regex, '^an/absolute/file/path(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'an/absolute/file/path',
			'an/absolute/file/path/foo',
			'foo/an/absolute/file/path',
		]))
		self.assertEqual(results, {
			'an/absolute/file/path',
			'an/absolute/file/path/foo',
		})
コード例 #24
0
	def test_03_inner_double_asterisk(self):
		"""
		Tests a path with an inner double-asterisk directory.

		This should match:

			left/bar/right
			left/foo/bar/right
			left/bar/right/foo

		This should **not** match (according to git check-ignore (v2.4.1)):

			foo/left/bar/right
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('left/**/right')
		self.assertTrue(include)
		self.assertEqual(regex, '^left(?:/.+)?/right(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'left/bar/right',
			'left/foo/bar/right',
			'left/bar/right/foo',
			'foo/left/bar/right',
		]))
		self.assertEqual(results, {
			'left/bar/right',
			'left/foo/bar/right',
			'left/bar/right/foo',
		})
コード例 #25
0
	def test_05_directory(self):
		"""
		Tests a directory pattern.

		This should match:

			dir/
			foo/dir/
			foo/dir/bar

		This should **not** match:

			dir
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('dir/')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?dir/.*$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'dir/',
			'foo/dir/',
			'foo/dir/bar',
			'dir',
		]))
		self.assertEqual(results, {
			'dir/',
			'foo/dir/',
			'foo/dir/bar',
		})
コード例 #26
0
	def test_01_relative_nested(self):
		"""
		Tests a relative nested path pattern.

		This should match:

			foo/spam
			foo/spam/bar

		This should **not** match (according to git check-ignore (v2.4.1)):

			bar/foo/spam
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('foo/spam')
		self.assertTrue(include)
		self.assertEqual(regex, '^foo/spam(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'foo/spam',
			'foo/spam/bar',
			'bar/foo/spam',
		]))
		self.assertEqual(results, {
			'foo/spam',
			'foo/spam/bar',
		})
コード例 #27
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_01_relative(self):
        """
		Tests a relative path pattern.

		This should match:

			spam
			spam/
			foo/spam
			spam/foo
			foo/spam/bar
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("spam")
        self.assertTrue(include)
        self.assertEqual(regex, "^(?:.+/)?spam(?:/.*)?$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(
            pattern.match([
                "spam",
                "spam/",
                "foo/spam",
                "spam/foo",
                "foo/spam/bar",
            ]))
        self.assertEqual(results, {
            "spam",
            "spam/",
            "foo/spam",
            "spam/foo",
            "foo/spam/bar",
        })
コード例 #28
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_07_match_unicode_and_unicode(self):
        """
		Test unicode patterns with unicode paths.
		"""
        pattern = GitWildMatchPattern("*.py")
        results = set(pattern.match(["a.py"]))
        self.assertEqual(results, {"a.py"})
コード例 #29
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_07_match_unicode_and_bytes_fail(self):
        """
		Test unicode patterns with byte paths.
		"""
        pattern = GitWildMatchPattern("*.py")
        with self.assertRaises(TypeError):
            for _ in pattern.match([b"a.py"]):
                pass
コード例 #30
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_07_match_bytes_and_unicode_fail(self):
        """
		Test byte string patterns matching byte string paths.
		"""
        pattern = GitWildMatchPattern(b"*.py")
        with self.assertRaises(TypeError):
            for _ in pattern.match(["a.py"]):
                pass
コード例 #31
0
	def test_07_match_bytes_and_unicode_fail(self):
		"""
		Test byte string patterns matching byte string paths.
		"""
		pattern = GitWildMatchPattern(b'*.py')
		with self.assertRaises(TypeError):
			for _ in pattern.match(['a.py']):
				pass
コード例 #32
0
	def test_07_match_unicode_and_bytes_fail(self):
		"""
		Test unicode patterns with byte paths.
		"""
		pattern = GitWildMatchPattern('*.py')
		with self.assertRaises(TypeError):
			for _ in pattern.match([b'a.py']):
				pass
コード例 #33
0
ファイル: test_gitwildmatch.py プロジェクト: Speira/my-vim
	def test_07_match_bytes_and_bytes_complete(self):
		"""
		Test byte string patterns matching byte string paths.
		"""
		encoded = bytes(bytearray(range(0,256)))
		escaped = b"".join(b"\\" + encoded[i:i+1] for i in range(len(encoded)))
		pattern = GitWildMatchPattern(escaped)
		results = set(pattern.match([encoded]))
		self.assertEqual(results, {encoded})
コード例 #34
0
	def test_07_match_bytes_and_bytes_complete(self):
		"""
		Test byte string patterns matching byte string paths.
		"""
		encoded = bytes(bytearray(range(0,256)))
		escaped = b"".join(b"\\" + encoded[i:i+1] for i in range(len(encoded)))
		pattern = GitWildMatchPattern(escaped)
		results = set(pattern.match([encoded]))
		self.assertEqual(results, {encoded})
コード例 #35
0
ファイル: test_gitwildmatch.py プロジェクト: otr0624/StoreApp
    def test_02_ignore(self):
        """
		Tests an exclude pattern.

		This should NOT match (according to git check-ignore (v2.4.1)):

			temp/foo
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("!temp")
        self.assertIsNotNone(include)
        self.assertFalse(include)
        self.assertEqual(regex, "^(?:.+/)?temp$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(pattern.match(["temp/foo"]))
        self.assertEqual(results, set())
コード例 #36
0
	def test_02_ignore(self):
		"""
		Tests an exclude pattern.

		This should NOT match (according to git check-ignore (v2.4.1)):

			temp/foo
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('!temp')
		self.assertIsNotNone(include)
		self.assertFalse(include)
		self.assertEqual(regex, '^(?:.+/)?temp$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match(['temp/foo']))
		self.assertEqual(results, set())
コード例 #37
0
    def test_03_child_double_asterisk(self):
        """
		Tests a directory name with a double-asterisk child
		directory.

		This should match:

			spam/bar

		This should **not** match (according to git check-ignore (v2.4.1)):

			foo/spam/bar
		"""
        regex, include = GitWildMatchPattern.pattern_to_regex("spam/**")
        self.assertTrue(include)
        self.assertEqual(regex, "^spam/.*$")

        pattern = GitWildMatchPattern(re.compile(regex), include)
        results = set(pattern.match(["spam/bar", "foo/spam/bar",]))
        self.assertEqual(results, {"spam/bar"})
コード例 #38
0
	def test_03_parent_double_asterisk(self):
		"""
		Tests a file name with a double-asterisk parent directory.

		This should match:

			foo/spam
			foo/spam/bar
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('**/spam')
		self.assertTrue(include)
		self.assertEqual(regex, '^(?:.+/)?spam(?:/.*)?$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'foo/spam',
			'foo/spam/bar',
		]))
		self.assertEqual(results, {
			'foo/spam',
			'foo/spam/bar',
		})
コード例 #39
0
	def test_03_child_double_asterisk(self):
		"""
		Tests a directory name with a double-asterisk child
		directory.

		This should match:

			spam/bar

		This should **not** match (according to git check-ignore (v2.4.1)):

			foo/spam/bar
		"""
		regex, include = GitWildMatchPattern.pattern_to_regex('spam/**')
		self.assertTrue(include)
		self.assertEqual(regex, '^spam/.*$')

		pattern = GitWildMatchPattern(re.compile(regex), include)
		results = set(pattern.match([
			'spam/bar',
			'foo/spam/bar',
		]))
		self.assertEqual(results, {'spam/bar'})