Separate the general from the WL-specific: PDF
[librarian.git] / tests / test_iofile.py
1 import os
2 from StringIO import StringIO
3 from tempfile import NamedTemporaryFile
4 from nose.tools import *
5 from librarian import IOFile
6
7 def test_iofile_from_string_reusable():
8     some_file = IOFile.from_string("test")
9     some_file.get_file().read()
10     assert_equal(some_file.get_file().read(), "test")
11
12 def test_iofile_from_filename_reusable():
13     temp = NamedTemporaryFile(delete=False)
14     try:
15         temp.write('test')
16         temp.close()
17         some_file = IOFile.from_filename(temp.name)
18         some_file.get_file().read()
19         assert_equal(some_file.get_file().read(), "test")
20     finally:
21         os.unlink(temp.name)