Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(876)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff_unittest.py

Issue 2580143002: Add Python html_diff module. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6
7 from webkitpy.common.html_diff import html_diff, html_diff_body
8
9
10 class TestHtmlDiff(unittest.TestCase):
11
12 def test_html_diff(self):
13 self.assertEqual(
14 html_diff('one\ntoo\nthree\n', 'one\ntwo\nthree\n'),
15 ('<html>\n'
16 '<head>\n'
17 '<style>.del { background: #faa; } .add { background: #afa; }</styl e>\n'
18 '</head>\n'
19 '<body>\n'
20 '<pre>one\n'
21 '<span class="del">too\n'
22 '</span><span class="add">two\n'
23 '</span>three\n'
24 '</pre>\n'
25 '</body>\n'
26 '</html>\n'))
27
28 def test_html_diff_same(self):
29 self.assertEqual(
30 html_diff_body(['one line\n'], ['one line\n']),
31 'one line\n')
32
33 def test_html_diff_delete(self):
34 self.assertEqual(
35 html_diff_body(['one line\n'], []),
36 '<span class="del">one line\n</span>')
37
38 def test_html_diff_insert(self):
39 self.assertEqual(
40 html_diff_body([], ['one line\n']),
41 '<span class="add">one line\n</span>')
42
43 def test_html_diff_ending_newline(self):
44 self.assertEqual(
45 html_diff_body(['one line'], ['one line\n']),
46 '<span class="del">one line</span><span class="add">one line\n</span >')
47
48 def test_html_diff_replace_multiple_lines(self):
49 a_lines = [
50 '1. Beautiful is better than ugly.\n',
51 '2. Explicit is better than implicit.\n',
52 '3. Simple is better than complex.\n',
53 '4. Complex is better than complicated.\n',
54 ]
55 b_lines = [
56 '1. Beautiful is better than ugly.\n',
57 '3. Simple is better than complex.\n',
58 '4. Complicated is better than complex.\n',
59 '5. Flat is better than nested.\n',
60 ]
61 self.assertEqual(html_diff_body(a_lines, b_lines), (
62 '1. Beautiful is better than ugly.\n'
63 '<span class="del">2. Explicit is better than implicit.\n'
64 '3. Simple is better than complex.\n'
65 '4. Complex is better than complicated.\n'
66 '</span><span class="add">3. Simple is better than complex.\n'
67 '4. Complicated is better than complex.\n'
68 '5. Flat is better than nested.\n'
69 '</span>'))
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/common/html_diff.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698