From cdd2be35481e2f7891791c4409849cfc7d2d3f6e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 14 Nov 2008 14:03:47 +0900 Subject: [PATCH] fix unit test, badstatusline error --- anki/sync.py | 8 +++++--- tests/test_sync.py | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/anki/sync.py b/anki/sync.py index 09f56f200..f938c0d37 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -21,7 +21,7 @@ createDeck(name): create a deck on the server __docformat__ = 'restructuredtext' import zlib, re, urllib, urllib2, socket, simplejson, time -import os, base64 +import os, base64, httplib from datetime import date import anki, anki.deck, anki.cards from anki.errors import * @@ -960,7 +960,8 @@ class HttpSyncServerProxy(SyncServer): data = urllib.urlencode(data) try: f = urllib2.urlopen(self.syncURL + action, data) - except (urllib2.URLError, socket.error, socket.timeout): + except (urllib2.URLError, socket.error, socket.timeout, + httplib.BadStatusLine): raise SyncError(type="noResponse") ret = f.read() if not ret: @@ -1092,7 +1093,8 @@ class BulkMediaSyncerProxy(HttpSyncServerProxy): data = urllib.urlencode(data) try: f = urllib2.urlopen(self.syncURL + action, data) - except (urllib2.URLError, socket.error, socket.timeout): + except (urllib2.URLError, socket.error, socket.timeout, + httplib.BadStatusLine): raise SyncError(type="noResponse") ret = f.read() if not ret: diff --git a/tests/test_sync.py b/tests/test_sync.py index bd54ece2c..62a6e3e4f 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -236,6 +236,7 @@ def test_localsync_media(): assert deck2.s.scalar("select count(1) from media") == 3 # check delete os.unlink(os.path.join(deck1media, "22161b29b0c18e068038021f54eee1ee.png")) + time.sleep(0.1) rebuildMediaDir(deck1) client.sync() assert deck1.s.scalar("select count(1) from media") == 2