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.

53 lines
1.8 KiB

4 years ago
  1. import unittest
  2. from gooey.gui.components.options import options
  3. class TestPrefixFilter(unittest.TestCase):
  4. def test_doc_schenanigans(self):
  5. """Sanity check that my docstring wrappers all behave as expected"""
  6. @options._include_layout_docs
  7. def no_self_docstring():
  8. pass
  9. @options._include_layout_docs
  10. def yes_self_docstring():
  11. """sup"""
  12. pass
  13. # gets attached to functions even if they don't have a docstring
  14. self.assertIn(options.LayoutOptions.__doc__, no_self_docstring.__doc__)
  15. # gets attached to the *end* of existing doc strings
  16. self.assertTrue(yes_self_docstring.__doc__.startswith('sup'))
  17. self.assertIn(options.LayoutOptions.__doc__, yes_self_docstring.__doc__)
  18. def test_clean_method(self):
  19. """
  20. _clean should drop any keys with None values
  21. and flatten the layout_option kwargs to the root level
  22. """
  23. result = options._clean({'a': None, 'b': 123, 'c': 0})
  24. self.assertEqual(result, {'b': 123, 'c': 0})
  25. result = options._clean({'root_level': 123, 'layout_options': {
  26. 'nested': 'hello',
  27. 'another': 1234
  28. }})
  29. self.assertEqual(result, {'root_level': 123, 'nested': 'hello', 'another': 1234})
  30. def test_only_provided_arguments_included(self):
  31. """
  32. More sanity checking that the internal use of locals()
  33. does the Right Thing
  34. """
  35. option = options.LayoutOptions(label_color='#ffffff')
  36. self.assertIn('label_color', option)
  37. option = options.LayoutOptions()
  38. self.assertNotIn('label_color', option)
  39. option = options.TextField(label_color='#ffffff')
  40. self.assertIn('label_color', option)
  41. option = options.TextField()
  42. self.assertNotIn('label_color', option)