test_DirectEntry.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # coding=utf-8
  2. from direct.gui.DirectEntry import DirectEntry
  3. def test_entry_destroy():
  4. entry = DirectEntry()
  5. entry.destroy()
  6. def test_entry_get():
  7. entry = DirectEntry()
  8. assert isinstance(entry.get(), str)
  9. def test_entry_auto_capitalize():
  10. # Now we can generate the DirectEntry component itself. In normal use, we
  11. # would pass "autoCapitalize=1" to DirectEntry's constructor in order for
  12. # DirectEntry._autoCapitalize() to be called upon typing into the entry
  13. # GUI, however in the case of this unit test where there is no GUI to type
  14. # into, we don't need to bother doing that; we're just calling the function
  15. # ourselves anyway.
  16. entry = DirectEntry()
  17. # Test DirectEntry._autoCapitalize(). The intended behavior would be that
  18. # the first letter of each word in the entry would be capitalized, so that
  19. # is what we will check for:
  20. entry.set('auto capitalize test')
  21. entry._autoCapitalize()
  22. assert entry.get() == 'Auto Capitalize Test'
  23. # Test DirectEntry._autoCapitalize() with a unicode object this time.
  24. entry.set(u'àütò çapítalízè ţèsţ')
  25. assert entry.get() == u'àütò çapítalízè ţèsţ'
  26. entry._autoCapitalize()
  27. assert entry.get() == u'Àütò Çapítalízè Ţèsţ'