Skip to content

Commit

Permalink
Merge pull request #212 from alastair/tests
Browse files Browse the repository at this point in the history
Fix independent test running (#211)

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
  • Loading branch information
mineo committed Dec 20, 2016
2 parents a955470 + e8b6d30 commit 0884d08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions musicbrainzngs/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
if is_py2:
from StringIO import StringIO
from urllib2 import HTTPPasswordMgr, HTTPDigestAuthHandler, Request,\
HTTPHandler, build_opener, HTTPError, URLError,\
build_opener
HTTPHandler, build_opener, HTTPError, URLError
from httplib import BadStatusLine, HTTPException
from urlparse import urlunparse
from urllib import urlencode
Expand Down
5 changes: 5 additions & 0 deletions test/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class ArgumentTest(unittest.TestCase):
def setUp(self):
self.opener = _common.FakeOpener("<response/>")
musicbrainzngs.compat.build_opener = lambda *args: self.opener
self.orig_do_rate_limit = musicbrainz.do_rate_limit
musicbrainz.do_rate_limit = False

def tearDown(self):
musicbrainz.do_rate_limit = self.orig_do_rate_limit

def test_no_client(self):
musicbrainzngs.set_useragent("testapp", "0.1", "test@example.org")
Expand Down
13 changes: 13 additions & 0 deletions test/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
from test import _common

class SubmitTest(unittest.TestCase):

def setUp(self):
self.orig_opener = musicbrainzngs.compat.build_opener
musicbrainz.set_useragent("test_client", "1.0")
musicbrainz.auth("user", "password")

def tearDown(self):
musicbrainzngs.compat.build_opener = self.orig_opener
musicbrainz._useragent = ""
musicbrainz._client = ""
musicbrainz.user = ""
musicbrainz.password = ""

def test_submit_tags(self):
self.opener = _common.FakeOpener("<response/>")
musicbrainzngs.compat.build_opener = lambda *args: self.opener
Expand Down

0 comments on commit 0884d08

Please sign in to comment.