1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/usr/bin/env python3
"""Test gtk3widgets.py."""
import os
import codecs
import shutil
import tempfile
import unittest
from aptdaemon.gtk3widgets import DiffView
class TestLP1120322(unittest.TestCase):
def setUp(self):
tempdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tempdir)
self.a = os.path.join(tempdir, 'a.txt')
self.b = os.path.join(tempdir, 'b.txt')
with codecs.open(self.a, 'w', encoding='utf-8') as f:
f.write('one\n')
with codecs.open(self.b, 'w', encoding='utf-8') as f:
f.write('onee\n')
def test_lp_1120322(self):
# UnboundLocalError when the diff is one line long.
dv = DiffView()
# This simply should not traceback.
dv.show_diff(self.a, self.b)
class TestGoodPath(unittest.TestCase):
def setUp(self):
tempdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tempdir)
self.a = os.path.join(tempdir, 'a.txt')
self.b = os.path.join(tempdir, 'b.txt')
with codecs.open(self.a, 'w', encoding='utf-8') as f:
f.write('one\ntwo\n')
with codecs.open(self.b, 'w', encoding='utf-8') as f:
f.write('one\ntoo\n')
def test_lp_1120322(self):
# UnboundLocalError when the diff is multiple lines long.
dv = DiffView()
# This simply should not traceback.
dv.show_diff(self.a, self.b)
|