diff options
| author | Matthew Poletiek <matthew.poletiek@gmail.com> | 2020-12-08 21:03:16 -0600 |
|---|---|---|
| committer | Matthew Poletiek <matthew.poletiek@gmail.com> | 2020-12-08 21:03:16 -0600 |
| commit | e99416456afd4aa8bde42016826f9a345291cbf3 (patch) | |
| tree | a7a95639cd1cb5dbe2d91a2ca8e8defafac4296d /tests/unit/base.py | |
| parent | 194cf4e5e0b6a2811103a9b739a72b9afe2b886c (diff) | |
| download | chirp-e99416456afd4aa8bde42016826f9a345291cbf3.tar.gz chirp-e99416456afd4aa8bde42016826f9a345291cbf3.tar.xz | |
Initial Commit
Diffstat (limited to 'tests/unit/base.py')
| -rw-r--r-- | tests/unit/base.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/base.py b/tests/unit/base.py new file mode 100644 index 0000000..1e112ce --- /dev/null +++ b/tests/unit/base.py @@ -0,0 +1,50 @@ +import sys +import unittest + +import mock + +try: + import mox +except ImportError: + from mox3 import mox + +import warnings +warnings.simplefilter('ignore', Warning) + + +class BaseTest(unittest.TestCase): + def setUp(self): + __builtins__['_'] = lambda s: s + self.mox = mox.Mox() + + def tearDown(self): + self.mox.UnsetStubs() + self.mox.VerifyAll() + + +pygtk_mocks = ('gtk', 'pango', 'gobject') +pygtk_base_classes = ('gobject.GObject', 'gtk.HBox', 'gtk.Dialog') + + +class DummyBase(object): + def __init__(self, *a, **k): + # gtk.Dialog + self.vbox = mock.MagicMock() + + # gtk.Dialog + def set_position(self, pos): + pass + + +def mock_gtk(): + for module in pygtk_mocks: + sys.modules[module] = mock.MagicMock() + + for path in pygtk_base_classes: + module, base_class = path.split('.') + setattr(sys.modules[module], base_class, DummyBase) + + +def unmock_gtk(): + for module in pygtk_mocks: + del sys.modules[module] |
