aboutsummaryrefslogtreecommitdiff
path: root/tests/test_gtk3widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_gtk3widgets.py')
-rw-r--r--tests/test_gtk3widgets.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_gtk3widgets.py b/tests/test_gtk3widgets.py
new file mode 100644
index 0000000..ca3d73f
--- /dev/null
+++ b/tests/test_gtk3widgets.py
@@ -0,0 +1,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)