[Python-porting] Doctests in single-source port

Dirkjan Ochtman dirkjan at ochtman.nl
Mon Mar 31 22:13:43 CEST 2014


Hi there,

I've just had another run at completing my single-source port of
CouchDB-Python (see [1]), trying to converge on something that passes
the test suite on both 2.7 and 3.3. However, I can't think of any
clever ways to deal with doctest failures I'm seeing. Are there any
established best practices or ugly hacks to make this easier? Here are
some typical failures:

======================================================================
FAIL: delete (couchdb.client.Database)
Doctest: couchdb.client.Database.delete
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.3/doctest.py", line 2154, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for couchdb.client.Database.delete
  File "./couchdb/client.py", line 512, in delete

----------------------------------------------------------------------
File "./couchdb/client.py", line 528, in couchdb.client.Database.delete
Failed example:
    db.delete(doc)
Expected:
    Traceback (most recent call last):
      ...
    ResourceConflict: (u'conflict', u'Document update conflict.')
Got:
    Traceback (most recent call last):
      File "/usr/lib/python3.3/doctest.py", line 1287, in __run
        compileflags, 1), test.globs)
      File "<doctest couchdb.client.Database.delete[7]>", line 1, in <module>
        db.delete(doc)
      File "./couchdb/client.py", line 541, in delete
        _doc_resource(self.resource, doc['_id']).delete_json(rev=doc['_rev'])
      File "./couchdb/http.py", line 530, in delete_json
        return self._request_json('DELETE', path, headers=headers, **params)
      File "./couchdb/http.py", line 556, in _request_json
        headers=headers, **params)
      File "./couchdb/http.py", line 552, in _request
        credentials=self.credentials)
      File "./couchdb/http.py", line 404, in request
        raise ResourceConflict(error)
    couchdb.http.ResourceConflict: ('conflict', 'Document update conflict.')

FAIL: ViewResults (couchdb.client)
Doctest: couchdb.client.ViewResults
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.3/doctest.py", line 2154, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for couchdb.client.ViewResults
  File "./couchdb/client.py", line 1097, in ViewResults

----------------------------------------------------------------------
File "./couchdb/client.py", line 1136, in couchdb.client.ViewResults
Failed example:
    list(results[['City', 'Gotham City']])
Expected:
    [<Row id=u'gotham', key=[u'City', u'Gotham City'], value=u'Gotham City'>]
Got:
    [<Row id='gotham', key=['City', 'Gotham City'], value='Gotham City'>]

Thanks for any suggestions,

Dirkjan

[1] https://code.google.com/p/couchdb-python/source/list?name=db566517e8af


More information about the Python-porting mailing list