summaryrefslogtreecommitdiff
path: root/tests/test_write.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_write.py')
-rw-r--r--tests/test_write.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/tests/test_write.py b/tests/test_write.py
index 28361b0..96d0792 100644
--- a/tests/test_write.py
+++ b/tests/test_write.py
@@ -1,7 +1,10 @@
from __future__ import absolute_import
-from ofxparse import OfxParser as op
+from ofxparse import OfxParser, OfxPrinter
from unittest import TestCase
+from six import StringIO
+from os import close, remove
+from tempfile import mkstemp
import sys
sys.path.append('..')
from .support import open_file
@@ -9,9 +12,25 @@ from .support import open_file
class TestOfxWrite(TestCase):
def test_write(self):
- test_file = open_file('fidelity.ofx')
- ofx_doc = op.parse(test_file)
- self.assertEqual(str(ofx_doc), "")
+ with open_file('fidelity.ofx') as f:
+ ofx = OfxParser.parse(f)
+ self.assertEqual(str(ofx), "")
+
+ def test_using_ofx_printer(self):
+ with open_file('checking.ofx') as f:
+ ofx = OfxParser.parse(f)
+ fd, name = mkstemp()
+ close(fd)
+ printer = OfxPrinter(ofx=ofx, filename=name)
+ printer.write(tabs=1)
+
+ def test_using_ofx_printer_with_stringio(self):
+ with open_file('checking.ofx') as f:
+ ofx = OfxParser.parse(f)
+ output_buffer = StringIO()
+ printer = OfxPrinter(ofx=ofx, filename=None)
+ printer.writeToFile(output_buffer, tabs=1)
+ assert output_buffer.getvalue().startswith("OFXHEADER")
if __name__ == "__main__":
import unittest