from __future__ import absolute_import

from ofxparse import OfxParser as op, OfxPrinter
from unittest import TestCase
from os import close, remove
from tempfile import mkstemp
import sys
sys.path.append('..')
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), "")

    def test_using_ofx_printer(self):
        test_file = open_file('checking.ofx')
        ofx_doc = op.parse(test_file)
        fd, name = mkstemp()
        close(fd)
        printer = OfxPrinter(ofx=ofx_doc, filename=name)
        printer.write(tabs=1)

if __name__ == "__main__":
    import unittest
    unittest.main()

from __future__ import absolute_import

from ofxparse import OfxParser, OfxPrinter
from unittest import TestCase
from os import close, remove
from tempfile import mkstemp
import sys
sys.path.append('..')
from .support import open_file


class TestOfxWrite(TestCase):
    def test_write(self):
        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)

if __name__ == "__main__":
    import unittest
    unittest.main()

Fix warnings under Python 3
Fix warnings under Python 3

  from __future__ import absolute_import
  
- from ofxparse import OfxParser as op, OfxPrinter
+ from ofxparse import OfxParser, OfxPrinter
  from unittest import TestCase
  from os import close, remove
  from tempfile import mkstemp
  import sys
  sys.path.append('..')
  from .support import open_file
  
  
  class TestOfxWrite(TestCase):
      def test_write(self):
-         test_file = open_file('fidelity.ofx')
+         with open_file('fidelity.ofx') as f:
-         ofx_doc = op.parse(test_file)
+             ofx = OfxParser.parse(f)
-         self.assertEqual(str(ofx_doc), "")
+         self.assertEqual(str(ofx), "")
  
      def test_using_ofx_printer(self):
-         test_file = open_file('checking.ofx')
+         with open_file('checking.ofx') as f:
-         ofx_doc = op.parse(test_file)
+             ofx = OfxParser.parse(f)
          fd, name = mkstemp()
          close(fd)
-         printer = OfxPrinter(ofx=ofx_doc, filename=name)
+         printer = OfxPrinter(ofx=ofx, filename=name)
          printer.write(tabs=1)
  
  if __name__ == "__main__":
      import unittest
      unittest.main()
  
Fix warnings under Python 3
## Code Before:
from __future__ import absolute_import

from ofxparse import OfxParser as op, OfxPrinter
from unittest import TestCase
from os import close, remove
from tempfile import mkstemp
import sys
sys.path.append('..')
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), "")

    def test_using_ofx_printer(self):
        test_file = open_file('checking.ofx')
        ofx_doc = op.parse(test_file)
        fd, name = mkstemp()
        close(fd)
        printer = OfxPrinter(ofx=ofx_doc, filename=name)
        printer.write(tabs=1)

if __name__ == "__main__":
    import unittest
    unittest.main()

## Instruction:
Fix warnings under Python 3
## Code After:
from __future__ import absolute_import

from ofxparse import OfxParser, OfxPrinter
from unittest import TestCase
from os import close, remove
from tempfile import mkstemp
import sys
sys.path.append('..')
from .support import open_file


class TestOfxWrite(TestCase):
    def test_write(self):
        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)

if __name__ == "__main__":
    import unittest
    unittest.main()
