[meld/deprecation-cleanup] test: Update tests to 'handle' resource construction
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/deprecation-cleanup] test: Update tests to 'handle' resource construction
- Date: Sun, 6 Jan 2019 02:15:00 +0000 (UTC)
commit d0cccee7646877e7909bf18701da8688e20fbaf0
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Jan 6 12:12:46 2019 +1000
test: Update tests to 'handle' resource construction
test/conftest.py | 9 +++++++++
test/dirdiff/test_files_same.py | 10 ++++++----
test/dirdiff/test_remove_blank_lines.py | 6 ++++--
test/test_chunk_actions.py | 8 ++++----
test/test_filediff.py | 6 +++---
5 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/test/conftest.py b/test/conftest.py
index 94688e62..f524ff09 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -14,3 +14,12 @@ def default_icon_theme():
'gi.repository.Gtk.IconTheme.get_default',
mock.Mock(spec=Gtk.IconTheme.get_default)):
yield
+
+
+@pytest.fixture(autouse=True)
+def template_resources():
+ from meld.ui import _gtktemplate
+ with mock.patch(
+ 'meld.ui._gtktemplate.validate_resource_path',
+ mock.Mock(return_value=True)):
+ yield
diff --git a/test/dirdiff/test_files_same.py b/test/dirdiff/test_files_same.py
index d71fea9e..53fb725e 100644
--- a/test/dirdiff/test_files_same.py
+++ b/test/dirdiff/test_files_same.py
@@ -1,10 +1,9 @@
-import pytest
-
from enum import Enum
from os import path
-from meld.dirdiff import _files_same
-from .fixture import make
+import pytest
+
+from .fixture import make
DiffResult = Enum('DiffResult', 'Same SameFiltered DodgySame DodgyDifferent Different FileError')
@@ -33,6 +32,7 @@ no_ignore_args['apply-text-filters'] = False
dodgy_args = dict(cmp_args)
dodgy_args['shallow-comparison'] = True
+
@pytest.mark.parametrize('files, regexes, comparison_args, expected', [
# empty file list
((), [], cmp_args, DiffResult.Same),
@@ -70,6 +70,8 @@ dodgy_args['shallow-comparison'] = True
(('diffs/a/crlftrailing.txt', 'diffs/b/lftrailing.txt'), [], no_ignore_args, DiffResult.Different),
])
def test_files_same(files, regexes, comparison_args, expected, differnt_dirs):
+ from meld.dirdiff import _files_same
+
files_path = abspath(*files)
result = _files_same(files_path, regexes, comparison_args)
actual = DiffResult(result + 1)
diff --git a/test/dirdiff/test_remove_blank_lines.py b/test/dirdiff/test_remove_blank_lines.py
index 5daae854..c14a5e93 100644
--- a/test/dirdiff/test_remove_blank_lines.py
+++ b/test/dirdiff/test_remove_blank_lines.py
@@ -1,5 +1,5 @@
import pytest
-from meld.dirdiff import remove_blank_lines
+
@pytest.mark.parametrize('txt, expected', [
# blank to be equal blank
@@ -25,5 +25,7 @@ from meld.dirdiff import remove_blank_lines
(b'\n\n\ncontent\n\n\ncontent\n\n\n', b'content\ncontent'),
])
def test_remove_blank_lines(txt, expected):
+ from meld.dirdiff import remove_blank_lines
+
result = remove_blank_lines(txt)
- assert result == expected
\ No newline at end of file
+ assert result == expected
diff --git a/test/test_chunk_actions.py b/test/test_chunk_actions.py
index b2c2c108..ba789e72 100644
--- a/test/test_chunk_actions.py
+++ b/test/test_chunk_actions.py
@@ -4,10 +4,6 @@ from unittest import mock
import pytest
from gi.repository import GtkSource
-import meld.meldbuffer
-from meld.filediff import FileDiff
-from meld.matchers.myers import DiffChunk
-
@pytest.mark.parametrize("text, newline, expected_text", [
# For the following tests, newlines and text match
@@ -30,6 +26,10 @@ from meld.matchers.myers import DiffChunk
("ree\r\neee\nqqq\r\n", GtkSource.NewlineType.CR_LF, 'ree\r\neee\nqqq'),
])
def test_delete_last_line_crlf(text, newline, expected_text):
+ import meld.meldbuffer
+ from meld.filediff import FileDiff
+ from meld.matchers.myers import DiffChunk
+
filediff = mock.Mock(FileDiff)
with mock.patch.multiple(
diff --git a/test/test_filediff.py b/test/test_filediff.py
index b0e5501e..59b9c256 100644
--- a/test/test_filediff.py
+++ b/test/test_filediff.py
@@ -4,9 +4,6 @@ from unittest import mock
import pytest
from gi.repository import Gtk
-from meld.filediff import FileDiff
-from meld.filters import FilterEntry
-
@pytest.mark.parametrize("text, ignored_ranges, expected_text", [
# 0123456789012345678901234567890123456789012345678901234567890123456789
@@ -73,6 +70,9 @@ from meld.filters import FilterEntry
])
def test_filter_text(text, ignored_ranges, expected_text):
+ from meld.filediff import FileDiff
+ from meld.filters import FilterEntry
+
filter_patterns = [
'#.*',
'/\*.*\*/',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]