summaryrefslogtreecommitdiff
path: root/tests/test_write.py
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2018-11-05 14:44:38 +0100
committerAndrej Shadura <andrewsh@debian.org>2018-11-05 14:44:38 +0100
commit4d73449bab819dddc8e7f52ddf01b6bacd2a7e40 (patch)
tree992d9135cdaf62c13cf05fb6bc73628b1d5c7577 /tests/test_write.py
parent8f6a863fcd6a0518ea8e3e1e863346553d0250ba (diff)
parent59c3ccc50d3504bfeb1a3f7e31ba806e2b5c3a07 (diff)
Update upstream source from tag 'upstream/0.19'
Update to upstream version '0.19' with Debian dir 0cc2866dc4222e919db114429121a55eadb99c77
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