From d92251d01942e945e753901f67658380ec72ad53 Mon Sep 17 00:00:00 2001 From: Yonathan Randolph Date: Fri, 6 Oct 2023 11:43:25 -0700 Subject: [PATCH] Fix a couple doctests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I still don’t run doctest though since python -m doctest fails on python3 (No module named 'http.client'; 'http' is not a package ) and there are doctest errors in other files. --- remoteobjects/fields.py | 8 +++++++- remoteobjects/listobject.py | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/remoteobjects/fields.py b/remoteobjects/fields.py index 8690444..519ae6f 100644 --- a/remoteobjects/fields.py +++ b/remoteobjects/fields.py @@ -437,11 +437,17 @@ class Link(AcceptsStringCls, Property): For example: + >>> from remoteobjects import RemoteObject + >>> from remoteobjects.fields import Link + >>> class Event(RemoteObject): pass + ... >>> class Item(RemoteObject): ... feed = Link(Event) ... >>> i = Item.get('http://example.com/item/') - >>> f = i.feed # f's URL: http://example.com/item/feed + >>> f = i.feed + >>> f._location + 'http://example.com/item/feed' Override the `__get__` method of a `Link` subclass to customize how the URLs to linked objects are constructed. diff --git a/remoteobjects/listobject.py b/remoteobjects/listobject.py index edacc07..c41fca6 100644 --- a/remoteobjects/listobject.py +++ b/remoteobjects/listobject.py @@ -88,6 +88,10 @@ class PageOf(with_metaclass(OfOf, type(PromiseObject))): new `PageObject` classes that contain objects of a specified other class, like so: + >>> from remoteobjects import RemoteObject + >>> from remoteobjects.listobject import PageObject, PageOf + >>> class Entry(RemoteObject): pass + ... >>> PageOfEntry = PageOf(Entry) This is equivalent to defining ``PageOfEntry`` yourself: @@ -167,6 +171,9 @@ class PageObject(with_metaclass(PageOf, SequenceProxy, PromiseObject)): `PageOf`, with the class reference you would use to construct an `Object` field. That is, these declarations are equivalent: + >>> from remoteobjects import fields, RemoteObject + >>> from remoteobjects.listobject import PageObject, PageOf + >>> class Entry(RemoteObject): pass >>> PageOfEntry = PageOf(Entry) >>> class PageOfEntry(PageObject):