Get rid of FakeDict
This commit is contained in:
parent
b9b4d4f0a9
commit
311b9f2034
@ -1,55 +0,0 @@
|
||||
# Copyright 2014 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||
#
|
||||
# This file is part of qutebrowser.
|
||||
#
|
||||
# qutebrowser is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# qutebrowser is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# pylint: disable=missing-docstring
|
||||
|
||||
"""Tests for the FakeDict class."""
|
||||
|
||||
import unittest
|
||||
from unittest import TestCase
|
||||
|
||||
from qutebrowser.utils.usertypes import FakeDict
|
||||
|
||||
|
||||
class FakeDictTests(TestCase):
|
||||
|
||||
"""Test the FakeDict usertype.
|
||||
|
||||
Attributes:
|
||||
fd: The FakeDict we're testing.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.fd = FakeDict("foo")
|
||||
|
||||
def test_getitem(self):
|
||||
"""Test getting items of the fakedict."""
|
||||
self.assertEqual(self.fd["eggs"], "foo")
|
||||
self.assertEqual(self.fd["bacon"], "foo")
|
||||
|
||||
def test_setitem(self):
|
||||
"""Test setting items of the FakeDict which should raise TypeError."""
|
||||
with self.assertRaises(TypeError):
|
||||
self.fd["eggs"] = "bar"
|
||||
|
||||
def test_repr(self):
|
||||
"""Test repr() on the FakeDict."""
|
||||
self.assertEqual(repr(self.fd), "FakeDict('foo')")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -28,7 +28,6 @@ from qutebrowser.models.completion import (
|
||||
CommandCompletionModel, SettingSectionCompletionModel,
|
||||
SettingOptionCompletionModel, SettingValueCompletionModel)
|
||||
from qutebrowser.models.basecompletion import NoCompletionsError
|
||||
from qutebrowser.utils.usertypes import FakeDict
|
||||
|
||||
|
||||
class Completer(QObject):
|
||||
|
@ -230,24 +230,6 @@ class NeighborList(collections.abc.Sequence):
|
||||
return self.curitem()
|
||||
|
||||
|
||||
class FakeDict:
|
||||
|
||||
"""A fake dictionary which always returns the same value.
|
||||
|
||||
Attributes:
|
||||
_val: The value to return.
|
||||
"""
|
||||
|
||||
def __init__(self, val):
|
||||
self._val = val
|
||||
|
||||
def __getitem__(self, _key):
|
||||
return self._val
|
||||
|
||||
def __repr__(self):
|
||||
return "FakeDict('{}')".format(self._val)
|
||||
|
||||
|
||||
# The mode of a Question.
|
||||
PromptMode = enum('yesno', 'text', 'user_pwd', 'alert')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user