Blame tests/test_fnmatch.py

Pierre-Yves Chibon e1d70f
#!/usr/bin/env python
Pierre-Yves Chibon e1d70f
# -*- coding: utf-8 -*-
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
"""
Pierre-Yves Chibon e1d70f
 (c) 2017 - Copyright Red Hat Inc
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
 Authors:
Pierre-Yves Chibon e1d70f
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Tests the fnmatch method of the stdlib to ensure it works as expected
Pierre-Yves Chibon e1d70f
elsewhere in the code.
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
"""
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon 67d1cc
from __future__ import unicode_literals, absolute_import
Aurélien Bompard dcf6f6
Pierre-Yves Chibon e1d70f
import os
Pierre-Yves Chibon e1d70f
import sys
Pierre-Yves Chibon e1d70f
import unittest
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
import fnmatch
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
class FnmatchTests(unittest.TestCase):
Pierre-Yves Chibon e1d70f
    """Tests for the streaming server."""
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
    def test_fnmatch(self):
Pierre-Yves Chibon e1d70f
        """ Test the matching done by fnmatch. """
Pierre-Yves Chibon e1d70f
        matrix = [
Pierre-Yves Chibon 73d120
            ["pagure", "*", True],
Pierre-Yves Chibon 73d120
            ["ns/pagure", "*", True],
Pierre-Yves Chibon 73d120
            ["forks/user/ns/pagure", "*", True],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "*", True],
Pierre-Yves Chibon 73d120
            ["pagure", "rpms/*", False],
Pierre-Yves Chibon 73d120
            ["rpms/pagure", "rpms/*", True],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "rpms/*", False],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "rpms/*", False],
Pierre-Yves Chibon 73d120
            ["pagure", "pagure", True],
Pierre-Yves Chibon 73d120
            ["rpms/pagure", "pagure", False],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "pagure", False],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "pagure", False],
Pierre-Yves Chibon 73d120
            ["pagure", "pag*", True],
Pierre-Yves Chibon 73d120
            ["rpms/pagure", "pag*", False],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "pag*", False],
Pierre-Yves Chibon 73d120
            ["forks/user/pagure", "pag*", False],
Pierre-Yves Chibon e1d70f
        ]
Pierre-Yves Chibon e1d70f
        for row in matrix:
Pierre-Yves Chibon e1d70f
            self.assertEqual(fnmatch.fnmatch(row[0], row[1]), row[2])
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon 73d120
if __name__ == "__main__":
Pierre-Yves Chibon e1d70f
    unittest.main(verbosity=2)