test_fnmatch.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. (c) 2017 - Copyright Red Hat Inc
  5. Authors:
  6. Pierre-Yves Chibon <pingou@pingoured.fr>
  7. Tests the fnmatch method of the stdlib to ensure it works as expected
  8. elsewhere in the code.
  9. """
  10. from __future__ import unicode_literals, absolute_import
  11. import os
  12. import sys
  13. import unittest
  14. import fnmatch
  15. class FnmatchTests(unittest.TestCase):
  16. """Tests for the streaming server."""
  17. def test_fnmatch(self):
  18. """ Test the matching done by fnmatch. """
  19. matrix = [
  20. ["pagure", "*", True],
  21. ["ns/pagure", "*", True],
  22. ["forks/user/ns/pagure", "*", True],
  23. ["forks/user/pagure", "*", True],
  24. ["pagure", "rpms/*", False],
  25. ["rpms/pagure", "rpms/*", True],
  26. ["forks/user/pagure", "rpms/*", False],
  27. ["forks/user/pagure", "rpms/*", False],
  28. ["pagure", "pagure", True],
  29. ["rpms/pagure", "pagure", False],
  30. ["forks/user/pagure", "pagure", False],
  31. ["forks/user/pagure", "pagure", False],
  32. ["pagure", "pag*", True],
  33. ["rpms/pagure", "pag*", False],
  34. ["forks/user/pagure", "pag*", False],
  35. ["forks/user/pagure", "pag*", False],
  36. ]
  37. for row in matrix:
  38. self.assertEqual(fnmatch.fnmatch(row[0], row[1]), row[2])
  39. if __name__ == "__main__":
  40. unittest.main(verbosity=2)