Merge "Fix unit tests failing in some cases"
This commit is contained in:
commit
695bb710c4
@ -13,10 +13,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from mock import patch
|
||||||
from swift.common.container_sync_realms import ContainerSyncRealms
|
from swift.common.container_sync_realms import ContainerSyncRealms
|
||||||
from test.unit import FakeLogger, temptree
|
from test.unit import FakeLogger, temptree
|
||||||
|
|
||||||
@ -41,9 +43,14 @@ class TestUtils(unittest.TestCase):
|
|||||||
with temptree([fname], [fcontents]) as tempdir:
|
with temptree([fname], [fcontents]) as tempdir:
|
||||||
logger = FakeLogger()
|
logger = FakeLogger()
|
||||||
fpath = os.path.join(tempdir, fname)
|
fpath = os.path.join(tempdir, fname)
|
||||||
os.chmod(tempdir, 0)
|
|
||||||
|
def _mock_getmtime(path):
|
||||||
|
raise OSError(errno.EACCES,
|
||||||
|
os.strerror(errno.EACCES) +
|
||||||
|
": '%s'" % (fpath))
|
||||||
|
with patch('os.path.getmtime', _mock_getmtime):
|
||||||
csr = ContainerSyncRealms(fpath, logger)
|
csr = ContainerSyncRealms(fpath, logger)
|
||||||
try:
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
logger.all_log_lines(),
|
logger.all_log_lines(),
|
||||||
{'error': [
|
{'error': [
|
||||||
@ -51,8 +58,6 @@ class TestUtils(unittest.TestCase):
|
|||||||
"'%s'" % (fpath, fpath)]})
|
"'%s'" % (fpath, fpath)]})
|
||||||
self.assertEqual(csr.mtime_check_interval, 300)
|
self.assertEqual(csr.mtime_check_interval, 300)
|
||||||
self.assertEqual(csr.realms(), [])
|
self.assertEqual(csr.realms(), [])
|
||||||
finally:
|
|
||||||
os.chmod(tempdir, 0700)
|
|
||||||
|
|
||||||
def test_empty(self):
|
def test_empty(self):
|
||||||
fname = 'container-sync-realms.conf'
|
fname = 'container-sync-realms.conf'
|
||||||
|
@ -4414,7 +4414,7 @@ class TestZeroCopy(unittest.TestCase):
|
|||||||
self.wsgi_greenlet = spawn(
|
self.wsgi_greenlet = spawn(
|
||||||
wsgi.server, listener, self.object_controller, NullLogger())
|
wsgi.server, listener, self.object_controller, NullLogger())
|
||||||
|
|
||||||
self.http_conn = httplib.HTTPConnection('localhost', port)
|
self.http_conn = httplib.HTTPConnection('127.0.0.1', port)
|
||||||
self.http_conn.connect()
|
self.http_conn.connect()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user