summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2016-08-07 00:18:22 +0200
committerFlorian Bruhin <git@the-compiler.org>2016-08-07 11:21:33 +0200
commit4abbe502894dc19d7882cf233980e191a913f283 (patch)
treea7cae9c5b0c1e1a43f6e1e6777ab0f07671c9e4f
parent363d4f4654278408e6671f84965f6d5a77142635 (diff)
downloadqutebrowser-4abbe502894dc19d7882cf233980e191a913f283.tar.gz
qutebrowser-4abbe502894dc19d7882cf233980e191a913f283.zip
tests: fix tests for misc.editor
Due to the change to NamedTemporaryFile, the _filename attribute was removed. We now have to use _file.name.
-rw-r--r--tests/unit/misc/test_editor.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index f9a5d4370..26828ee12 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -69,14 +69,14 @@ class TestArg:
config_stub.data['general']['editor'] = ['bin', 'foo', '{}', 'bar']
editor.edit("")
editor._proc._proc.start.assert_called_with(
- "bin", ["foo", editor._filename, "bar"])
+ "bin", ["foo", editor._file.name, "bar"])
def test_placeholder_inline(self, config_stub, editor):
"""Test starting editor with placeholder arg inside of another arg."""
config_stub.data['general']['editor'] = ['bin', 'foo{}', 'bar']
editor.edit("")
editor._proc._proc.start.assert_called_with(
- "bin", ["foo" + editor._filename, "bar"])
+ "bin", ["foo" + editor._file.name, "bar"])
class TestFileHandling:
@@ -86,7 +86,7 @@ class TestFileHandling:
def test_ok(self, editor):
"""Test file handling when closing with an exit status == 0."""
editor.edit("")
- filename = editor._filename
+ filename = editor._file.name
assert os.path.exists(filename)
assert os.path.basename(filename).startswith('qutebrowser-editor-')
editor._proc.finished.emit(0, QProcess.NormalExit)
@@ -95,7 +95,7 @@ class TestFileHandling:
def test_error(self, editor):
"""Test file handling when closing with an exit status != 0."""
editor.edit("")
- filename = editor._filename
+ filename = editor._file.name
assert os.path.exists(filename)
editor._proc._proc.exitStatus = mock.Mock(
@@ -109,7 +109,7 @@ class TestFileHandling:
def test_crash(self, editor):
"""Test file handling when closing with a crash."""
editor.edit("")
- filename = editor._filename
+ filename = editor._file.name
assert os.path.exists(filename)
editor._proc._proc.exitStatus = mock.Mock(
@@ -125,7 +125,7 @@ class TestFileHandling:
def test_unreadable(self, message_mock, editor):
"""Test file handling when closing with an unreadable file."""
editor.edit("")
- filename = editor._filename
+ filename = editor._file.name
assert os.path.exists(filename)
os.chmod(filename, 0o077)
editor._proc.finished.emit(0, QProcess.NormalExit)
@@ -160,10 +160,10 @@ def test_modify(editor, initial_text, edited_text):
"""Test if inputs get modified correctly."""
editor.edit(initial_text)
- with open(editor._filename, 'r', encoding='utf-8') as f:
+ with open(editor._file.name, 'r', encoding='utf-8') as f:
assert f.read() == initial_text
- with open(editor._filename, 'w', encoding='utf-8') as f:
+ with open(editor._file.name, 'w', encoding='utf-8') as f:
f.write(edited_text)
editor._proc.finished.emit(0, QProcess.NormalExit)