Skip to content

Commit 834936a

Browse files
committed
Fix tests to run against non-standard server URL.
1 parent 26624b0 commit 834936a

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

couchdb/client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"""Python client API for CouchDB.
1010
11-
>>> server = Server('http://localhost:5984/')
11+
>>> server = Server()
1212
>>> db = server.create('python-tests')
1313
>>> doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
1414
>>> doc = db[doc_id]
@@ -43,7 +43,7 @@
4343
class Server(object):
4444
"""Representation of a CouchDB server.
4545
46-
>>> server = Server('http://localhost:5984/')
46+
>>> server = Server()
4747
4848
This class behaves like a dictionary of databases. For example, to get a
4949
list of database names on the server, you can simply iterate over the
@@ -218,7 +218,7 @@ def replicate(self, source, target, **options):
218218
class Database(object):
219219
"""Representation of a database on a CouchDB server.
220220
221-
>>> server = Server('http://localhost:5984/')
221+
>>> server = Server()
222222
>>> db = server.create('python-tests')
223223
224224
New documents can be added to the database using the `save()` method:
@@ -486,7 +486,7 @@ def delete(self, doc):
486486
the document has been updated since it was retrieved, this method will
487487
raise a `ResourceConflict` exception.
488488
489-
>>> server = Server('http://localhost:5984/')
489+
>>> server = Server()
490490
>>> db = server.create('python-tests')
491491
492492
>>> doc = dict(type='Person', name='John Doe')
@@ -640,7 +640,7 @@ def query(self, map_fun, reduce_fun=None, language='javascript',
640640
wrapper=None, **options):
641641
"""Execute an ad-hoc query (a "temp view") against the database.
642642
643-
>>> server = Server('http://localhost:5984/')
643+
>>> server = Server()
644644
>>> db = server.create('python-tests')
645645
>>> db['johndoe'] = dict(type='Person', name='John Doe')
646646
>>> db['maryjane'] = dict(type='Person', name='Mary Jane')
@@ -683,7 +683,7 @@ def update(self, documents, **options):
683683
"""Perform a bulk update or insertion of the given documents using a
684684
single HTTP request.
685685
686-
>>> server = Server('http://localhost:5984/')
686+
>>> server = Server()
687687
>>> db = server.create('python-tests')
688688
>>> for doc in db.update([
689689
... Document(type='Person', name='John Doe'),
@@ -751,7 +751,7 @@ def update(self, documents, **options):
751751
def view(self, name, wrapper=None, **options):
752752
"""Execute a predefined view.
753753
754-
>>> server = Server('http://localhost:5984/')
754+
>>> server = Server()
755755
>>> db = server.create('python-tests')
756756
>>> db['gotham'] = dict(type='City', name='Gotham City')
757757
@@ -920,7 +920,7 @@ class ViewResults(object):
920920
This class allows the specification of ``key``, ``startkey``, and
921921
``endkey`` options using Python slice notation.
922922
923-
>>> server = Server('http://localhost:5984/')
923+
>>> server = Server()
924924
>>> db = server.create('python-tests')
925925
>>> db['johndoe'] = dict(type='Person', name='John Doe')
926926
>>> db['maryjane'] = dict(type='Person', name='Mary Jane')

couchdb/design.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ViewDefinition(object):
2727
with the definition in the application code.
2828
2929
>>> from couchdb import Server
30-
>>> server = Server('http://localhost:5984/')
30+
>>> server = Server()
3131
>>> db = server.create('python-tests')
3232
3333
>>> view = ViewDefinition('tests', 'all', '''function(doc) {

couchdb/mapping.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""Mapping from raw JSON data structures to Python objects and vice versa.
1010
1111
>>> from couchdb import Server
12-
>>> server = Server('http://localhost:5984/')
12+
>>> server = Server()
1313
>>> db = server.create('python-tests')
1414
1515
To define a document mapping, you declare a Python class inherited from
@@ -206,7 +206,7 @@ class ViewField(object):
206206
That property can be used as a function, which will execute the view.
207207
208208
>>> from couchdb import Database
209-
>>> db = Database('http://localhost:5984/python-tests')
209+
>>> db = Database('python-tests')
210210
211211
>>> Person.by_name(db, count=3)
212212
<ViewResults <PermanentView '_design/people/_view/by_name'> {'count': 3}>
@@ -527,7 +527,7 @@ class DictField(Field):
527527
"""Field type for nested dictionaries.
528528
529529
>>> from couchdb import Server
530-
>>> server = Server('http://localhost:5984/')
530+
>>> server = Server()
531531
>>> db = server.create('python-tests')
532532
533533
>>> class Post(Document):
@@ -580,7 +580,7 @@ class ListField(Field):
580580
"""Field type for sequences of other fields.
581581
582582
>>> from couchdb import Server
583-
>>> server = Server('http://localhost:5984/')
583+
>>> server = Server()
584584
>>> db = server.create('python-tests')
585585
586586
>>> class Post(Document):

couchdb/tests/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import tempfile
1616
import threading
1717
import unittest
18+
import urlparse
1819

1920
from couchdb import client, http
2021
from couchdb.tests import testutil
@@ -442,7 +443,8 @@ def test_changes_releases_conn(self):
442443
# Consume an entire changes feed to read the whole response, then check
443444
# that the HTTP connection made it to the pool.
444445
list(self.db.changes(feed='continuous', timeout=0))
445-
self.assertTrue(self.db.resource.session.conns[('http', 'localhost:5984')])
446+
scheme, netloc = urlparse.urlsplit(client.DEFAULT_BASE_URL)[:2]
447+
self.assertTrue(self.db.resource.session.conns[(scheme, netloc)])
446448

447449
def test_changes_releases_conn_when_lastseq(self):
448450
# Consume a changes feed, stopping at the 'last_seq' item, i.e. don't
@@ -451,7 +453,8 @@ def test_changes_releases_conn_when_lastseq(self):
451453
for obj in self.db.changes(feed='continuous', timeout=0):
452454
if 'last_seq' in obj:
453455
break
454-
self.assertTrue(self.db.resource.session.conns[('http', 'localhost:5984')])
456+
scheme, netloc = urlparse.urlsplit(client.DEFAULT_BASE_URL)[:2]
457+
self.assertTrue(self.db.resource.session.conns[(scheme, netloc)])
455458

456459
def test_changes_conn_usable(self):
457460
# Consume a changes feed to get a used connection in the pool.

couchdb/tests/testutil.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# This software is licensed as described in the file COPYING, which
77
# you should have received as part of this distribution.
88

9-
import os
109
import uuid
1110
from couchdb import client
1211

0 commit comments

Comments
 (0)