X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/12b5230d8fdb3ad995e867fb5d58a69e8a627e68..ddeba8a8483dc73d0103030afe46fc5bce51d8a0:/tests/test_html_fragments.py?ds=inline diff --git a/tests/test_html_fragments.py b/tests/test_html_fragments.py index 3e87a9e..a89e94f 100644 --- a/tests/test_html_fragments.py +++ b/tests/test_html_fragments.py @@ -1,18 +1,20 @@ -# -*- coding: utf-8 -*- -# # This file is part of Librarian, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # +import unittest from librarian.html import extract_fragments -from nose.tools import * -from utils import get_fixture +from .utils import get_fixture + +class FragmentsTest(unittest.TestCase): + maxDiff = None -def test_fragments(): - expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_fragments.html') + def test_fragments(self): + expected_output_file_path = get_fixture('text', 'asnyk_miedzy_nami_fragments.html') - closed_fragments, open_fragments = extract_fragments( - get_fixture('text', 'asnyk_miedzy_nami_expected.html')) - assert not open_fragments - fragments_text = u"\n\n".join(u"%s: %s\n%s" % (f.id, f.themes, f) for f in closed_fragments.values()) - assert_equal(fragments_text, file(expected_output_file_path).read().decode('utf-8')) + closed_fragments, open_fragments = extract_fragments( + get_fixture('text', 'asnyk_miedzy_nami_expected.html')) + assert not open_fragments + fragments_text = "\n\n".join("%s: %s\n%s" % (f.id, f.themes, f) for f in sorted(closed_fragments.values(), key=lambda f: f.id)) + with open(expected_output_file_path, 'rb') as f: + self.assertEqual(fragments_text, f.read().decode('utf-8'))