-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_pyfuck.py
35 lines (26 loc) · 859 Bytes
/
test_pyfuck.py
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
import unittest
import os
import pyfuck
class TestPyFuck(unittest.TestCase):
to_parse = ('++++++++++[>++++>++++++++>++++++++++>+++++++++++>++++++'
'++++++<<<<<-]>>.>>>+.<<<----------.<++.>>-.>---.')
test_file = '.test'
def setUp(self):
self.fd = open(self.test_file, 'w+')
def tearDown(self):
self.fd.close()
os.remove(self.test_file)
def assertion(self):
# head to the start of the file for output
self.fd.seek(0, 0)
text = self.fd.read()
self.assertEqual(text, 'PyF*ck\n')
def test_evals_pyfuck(self):
p = pyfuck.PyFuck(self.to_parse, outfile=self.fd)
p.parse()
self.assertion()
def test_api(self):
pyfuck.parse(self.to_parse, outfile=self.fd)
self.assertion()
if __name__ == '__main__':
unittest.main()