Skip to content

Commit 1fe5e15

Browse files
4B796C65@gmail.com4B796C65@gmail.com
authored andcommitted
Started work on unit testing. But a bug prevents me from finishing it.
1 parent 16ba5b2 commit 1fe5e15

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

unittest/runTest.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import unittest
4+
import time
5+
import random
6+
import atexit
7+
atexit.register(lambda: time.sleep(3))
8+
9+
sys.path.insert(0, '..')
10+
import tdl
11+
12+
class SimpleConsoleTest(unittest.TestCase):
13+
14+
def setUp(self):
15+
self.console = tdl.init(30, 20, 'TDL UnitTest')
16+
17+
def tearDown(self):
18+
del self.console
19+
20+
class DrawCharTest(SimpleConsoleTest):
21+
22+
def test_dcTuples(self):
23+
self.console.clear()
24+
ch = (1, (255, 255, 255), (0, 0, 0))
25+
self.console.drawChar(0, 0, *ch)
26+
tdl.flush()
27+
# a critcal error with getChar prevents testing, I'll need to update libtcod
28+
self.assertEqual(ch, self.console.getChar(0, 0), 'err?')
29+
30+
def suite():
31+
loader = unittest.TestLoader()
32+
return unittest.TestSuite([loader.loadTestsFromTestCase(DrawCharTest)])
33+
34+
if __name__ == '__main__':
35+
unittest.TextTestRunner().run(suite())
36+

0 commit comments

Comments
 (0)