X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/d9dc96ea261fdeed57bbb57c4405003893668d8d..fe8e5b5e224d32baebbdaa2fecf4a847ed4e5354:/tests/test_iofile.py diff --git a/tests/test_iofile.py b/tests/test_iofile.py new file mode 100644 index 0000000..097a65a --- /dev/null +++ b/tests/test_iofile.py @@ -0,0 +1,21 @@ +import os +from StringIO import StringIO +from tempfile import NamedTemporaryFile +from nose.tools import * +from librarian import IOFile + +def test_iofile_from_string_reusable(): + some_file = IOFile.from_string("test") + some_file.get_file().read() + assert_equal(some_file.get_file().read(), "test") + +def test_iofile_from_filename_reusable(): + temp = NamedTemporaryFile(delete=False) + try: + temp.write('test') + temp.close() + some_file = IOFile.from_filename(temp.name) + some_file.get_file().read() + assert_equal(some_file.get_file().read(), "test") + finally: + os.unlink(temp.name)