File: test_fnmatch.py

package info (click to toggle)
pagure 5.11.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,640 kB
  • sloc: python: 113,281; javascript: 23,100; makefile: 194; sh: 66
file content (52 lines) | stat: -rw-r--r-- 1,427 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
 (c) 2017 - Copyright Red Hat Inc

 Authors:
   Pierre-Yves Chibon <pingou@pingoured.fr>

Tests the fnmatch method of the stdlib to ensure it works as expected
elsewhere in the code.

"""

from __future__ import unicode_literals, absolute_import

import os
import sys
import unittest

import fnmatch


class FnmatchTests(unittest.TestCase):
    """Tests for the streaming server."""

    def test_fnmatch(self):
        """ Test the matching done by fnmatch. """
        matrix = [
            ["pagure", "*", True],
            ["ns/pagure", "*", True],
            ["forks/user/ns/pagure", "*", True],
            ["forks/user/pagure", "*", True],
            ["pagure", "rpms/*", False],
            ["rpms/pagure", "rpms/*", True],
            ["forks/user/pagure", "rpms/*", False],
            ["forks/user/pagure", "rpms/*", False],
            ["pagure", "pagure", True],
            ["rpms/pagure", "pagure", False],
            ["forks/user/pagure", "pagure", False],
            ["forks/user/pagure", "pagure", False],
            ["pagure", "pag*", True],
            ["rpms/pagure", "pag*", False],
            ["forks/user/pagure", "pag*", False],
            ["forks/user/pagure", "pag*", False],
        ]
        for row in matrix:
            self.assertEqual(fnmatch.fnmatch(row[0], row[1]), row[2])


if __name__ == "__main__":
    unittest.main(verbosity=2)