test_fnmatch.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. import os
  11. import sys
  12. import unittest
  13. import fnmatch
  14. class FnmatchTests(unittest.TestCase):
  15. """Tests for the streaming server."""
  16. def test_fnmatch(self):
  17. """ Test the matching done by fnmatch. """
  18. matrix = [
  19. ['pagure', '*', True],
  20. ['ns/pagure', '*', True],
  21. ['forks/user/ns/pagure', '*', True],
  22. ['forks/user/pagure', '*', True],
  23. ['pagure', 'rpms/*', False],
  24. ['rpms/pagure', 'rpms/*', True],
  25. ['forks/user/pagure', 'rpms/*', False],
  26. ['forks/user/pagure', 'rpms/*', False],
  27. ['pagure', 'pagure', True],
  28. ['rpms/pagure', 'pagure', False],
  29. ['forks/user/pagure', 'pagure', False],
  30. ['forks/user/pagure', 'pagure', False],
  31. ['pagure', 'pag*', True],
  32. ['rpms/pagure', 'pag*', False],
  33. ['forks/user/pagure', 'pag*', False],
  34. ['forks/user/pagure', 'pag*', False],
  35. ]
  36. for row in matrix:
  37. self.assertEqual(fnmatch.fnmatch(row[0], row[1]), row[2])
  38. if __name__ == '__main__':
  39. unittest.main(verbosity=2)