style
[librarian.git] / tests / test_iofile.py
1 # -*- coding: utf-8 -*-
2 #
3 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 #
6 import os
7 from tempfile import NamedTemporaryFile
8 from nose.tools import *
9 from librarian import IOFile
10
11
12 def test_iofile_from_string_reusable():
13     some_file = IOFile.from_string("test")
14     some_file.get_file().read()
15     assert_equal(some_file.get_file().read(), "test")
16
17
18 def test_iofile_from_filename_reusable():
19     temp = NamedTemporaryFile(delete=False)
20     try:
21         temp.write('test')
22         temp.close()
23         some_file = IOFile.from_filename(temp.name)
24         some_file.get_file().read()
25         assert_equal(some_file.get_file().read(), "test")
26     finally:
27         os.unlink(temp.name)