You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1 KiB

  1. import argparse
  2. import os
  3. import unittest
  4. from gooey.gui.components.widgets.core import chooser
  5. class MockWxMDD:
  6. def GetPaths(self):
  7. pass
  8. class TestChooserResults(unittest.TestCase):
  9. def test_multiDirChooserGetResult(self):
  10. expected_outputs = [
  11. (None, "", [""]),
  12. # Windows
  13. ('nt', "C:", ["OS and System (C:)"]),
  14. ('nt', "D:\\A Folder\\Yep Another One",
  15. ["Other Stuff (D:)\\A Folder\\Yep Another One"]),
  16. ('nt', "A:\\Wow Remember Floppy Drives;E:\\Righto Then",
  17. ["Flipflop (A:)\\Wow Remember Floppy Drives",
  18. "Elephants Only (E:)\\Righto Then"])
  19. ]
  20. for osname, expected, pathsoutput in expected_outputs:
  21. if not osname or osname == os.name:
  22. chooser.MDD.MultiDirDialog = MockWxMDD
  23. chooser.MDD.MultiDirDialog.GetPaths = lambda self : pathsoutput
  24. result = chooser.MultiDirChooser.getResult(None, MockWxMDD())
  25. print(result)
  26. self.assertEqual(result, expected)
  27. if __name__ == '__main__':
  28. unittest.main()