Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kmaehashi committed Apr 22, 2016
1 parent 5475fed commit badf440
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion jubakit/test/loader/test_core.py
Expand Up @@ -3,8 +3,9 @@
from __future__ import absolute_import, division, print_function, unicode_literals

from unittest import TestCase

from io import StringIO
from tempfile import NamedTemporaryFile as TempFile

from jubakit.loader.core import LineBasedStreamLoader, LineBasedFileLoader

class LineBasedStreamLoaderTest(TestCase):
Expand All @@ -18,3 +19,18 @@ def test_simple(self):
lines.append(line)

self.assertEqual([{'line': 'hello\n'}, {'line': 'world'}], lines)

class LineBasedFileLoaderTest(TestCase):
def test_simple(self):
data = 'hello\nworld'
lines = []

with TempFile() as f:
f.write(data.encode())
f.flush()
loader = LineBasedFileLoader(f.name)

for line in loader:
lines.append(line)

self.assertEqual([{'line': 'hello\n'}, {'line': 'world'}], lines)

0 comments on commit badf440

Please sign in to comment.