mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-13 08:01:09 +00:00
Dropping mox
This commit is contained in:
parent
a46a78b97f
commit
7d70b6b3a3
@ -20,12 +20,14 @@ import __builtin__
|
||||
import os.path
|
||||
import shutil
|
||||
import StringIO
|
||||
from io import BytesIO
|
||||
import tempfile
|
||||
import types
|
||||
import urllib2
|
||||
|
||||
import debian.deb822
|
||||
import httplib2
|
||||
import mock
|
||||
import mox
|
||||
|
||||
import ubuntutools.archive
|
||||
@ -44,15 +46,11 @@ def setUpModule():
|
||||
ex_pkg.cleanup()
|
||||
|
||||
|
||||
class DscVerificationTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
class DscVerificationTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(DscVerificationTestCase, self).setUp()
|
||||
with open('test-data/example_1.0-1.dsc', 'rb') as f:
|
||||
self.dsc = ubuntutools.archive.Dsc(f.read())
|
||||
|
||||
def tearDown(self):
|
||||
super(DscVerificationTestCase, self).tearDown()
|
||||
|
||||
def test_good(self):
|
||||
self.assertTrue(self.dsc.verify_file(
|
||||
'test-data/example_1.0.orig.tar.gz'))
|
||||
@ -68,10 +66,10 @@ class DscVerificationTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
with open(fn, 'rb') as f:
|
||||
data = f.read()
|
||||
data = data[:-1] + chr(ord(data[-1]) ^ 8)
|
||||
self.mox.StubOutWithMock(__builtin__, 'open')
|
||||
open(fn, 'rb').AndReturn(StringIO.StringIO(data))
|
||||
self.mox.ReplayAll()
|
||||
self.assertFalse(self.dsc.verify_file(fn))
|
||||
m = mock.MagicMock(name='open', spec=open)
|
||||
m.return_value = BytesIO(data)
|
||||
with mock.patch('__builtin__.open', m):
|
||||
self.assertFalse(self.dsc.verify_file(fn))
|
||||
|
||||
def test_sha1(self):
|
||||
del self.dsc['Checksums-Sha256']
|
||||
|
@ -19,15 +19,16 @@ import __builtin__
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
from io import BytesIO
|
||||
from StringIO import StringIO
|
||||
|
||||
import mox
|
||||
import mock
|
||||
|
||||
from ubuntutools.config import UDTConfig, ubu_email
|
||||
from ubuntutools.logger import Logger
|
||||
from ubuntutools.test import unittest
|
||||
|
||||
class ConfigTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
class ConfigTestCase(unittest.TestCase):
|
||||
_config_files = {
|
||||
'system': '',
|
||||
'user': '',
|
||||
@ -42,11 +43,16 @@ class ConfigTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
}
|
||||
if filename not in files:
|
||||
raise IOError("No such file or directory: '%s'" % filename)
|
||||
return StringIO(files[filename])
|
||||
return BytesIO(files[filename])
|
||||
|
||||
def setUp(self):
|
||||
super(ConfigTestCase, self).setUp()
|
||||
self.mox.stubs.Set(__builtin__, 'open', self._fake_open)
|
||||
m = mock.mock_open()
|
||||
m.side_effect = self._fake_open
|
||||
patcher = mock.patch('__builtin__.open', m)
|
||||
self.addCleanup(patcher.stop)
|
||||
self.MockOpen = self.patcher.start()
|
||||
|
||||
Logger.stdout = StringIO()
|
||||
Logger.stderr = StringIO()
|
||||
|
||||
|
@ -21,7 +21,7 @@ import os
|
||||
import StringIO
|
||||
import sys
|
||||
|
||||
import mox
|
||||
import mock
|
||||
|
||||
from ubuntutools.logger import Logger
|
||||
from ubuntutools.test import unittest
|
||||
@ -186,7 +186,7 @@ Package: seahorse-plugins
|
||||
"""
|
||||
|
||||
#pylint: disable=R0904
|
||||
class UpdateMaintainerTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
class UpdateMaintainerTestCase(unittest.TestCase):
|
||||
"""TestCase object for ubuntutools.update_maintainer"""
|
||||
|
||||
_directory = "/"
|
||||
@ -216,9 +216,15 @@ class UpdateMaintainerTestCase(mox.MoxTestBase, unittest.TestCase):
|
||||
|
||||
#pylint: disable=C0103
|
||||
def setUp(self):
|
||||
super(UpdateMaintainerTestCase, self).setUp()
|
||||
self.mox.stubs.Set(__builtin__, 'open', self._fake_open)
|
||||
self.mox.stubs.Set(os.path, 'isfile', self._fake_isfile)
|
||||
m = mock.mock_open()
|
||||
m.side_effect = self._fake_open
|
||||
patcher = mock.patch('__builtin__.open', m)
|
||||
self.addCleanup(patcher.stop)
|
||||
self.MockOpen = patcher.start()
|
||||
m = mock.MagicMock(side_effect=self._fake_isfile)
|
||||
patcher = mock.patch('os.path.isfile', m)
|
||||
self.addCleanup(patcher.stop)
|
||||
self.MockIsfile = patcher.start()
|
||||
self._files["rules"] = StringIO.StringIO(_SIMPLE_RULES)
|
||||
Logger.stdout = StringIO.StringIO()
|
||||
Logger.stderr = StringIO.StringIO()
|
||||
|
Loading…
x
Reference in New Issue
Block a user