forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_DirectEntry.py
More file actions
35 lines (27 loc) · 1.25 KB
/
test_DirectEntry.py
File metadata and controls
35 lines (27 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# coding=utf-8
from direct.gui.DirectEntry import DirectEntry
def test_entry_destroy():
entry = DirectEntry()
entry.destroy()
def test_entry_get():
entry = DirectEntry()
assert isinstance(entry.get(), str)
def test_entry_auto_capitalize():
# Now we can generate the DirectEntry component itself. In normal use, we
# would pass "autoCapitalize=1" to DirectEntry's constructor in order for
# DirectEntry._autoCapitalize() to be called upon typing into the entry
# GUI, however in the case of this unit test where there is no GUI to type
# into, we don't need to bother doing that; we're just calling the function
# ourselves anyway.
entry = DirectEntry()
# Test DirectEntry._autoCapitalize(). The intended behavior would be that
# the first letter of each word in the entry would be capitalized, so that
# is what we will check for:
entry.set('auto capitalize test')
entry._autoCapitalize()
assert entry.get() == 'Auto Capitalize Test'
# Test DirectEntry._autoCapitalize() with a unicode object this time.
entry.set(u'àütò çapítalízè ţèsţ')
assert entry.get() == u'àütò çapítalízè ţèsţ'
entry._autoCapitalize()
assert entry.get() == u'Àütò Çapítalízè Ţèsţ'