Make doctest examples compatible with Python 2 and Python 3.
Existing doctests were written only for Python 2 and have not yet been updated upstream to work with Python 3. Last-Update: 2015-05-16 Gbp-Pq: Name 001.doctests-compatible-py2and3.patch
This commit is contained in:
parent
3909b840d0
commit
49b8fc1ef3
|
@ -231,14 +231,14 @@ This example is the "hello world" for the :mod:`lockfile` package::
|
||||||
from lockfile import LockFile
|
from lockfile import LockFile
|
||||||
lock = LockFile("/some/file/or/other")
|
lock = LockFile("/some/file/or/other")
|
||||||
with lock:
|
with lock:
|
||||||
print lock.path, 'is locked.'
|
print(lock.path, "is locked.")
|
||||||
|
|
||||||
To use this with Python 2.4, you can execute::
|
To use this with Python 2.4, you can execute::
|
||||||
|
|
||||||
from lockfile import LockFile
|
from lockfile import LockFile
|
||||||
lock = LockFile("/some/file/or/other")
|
lock = LockFile("/some/file/or/other")
|
||||||
lock.acquire()
|
lock.acquire()
|
||||||
print lock.path, 'is locked.'
|
print(lock.path, "is locked.")
|
||||||
lock.release()
|
lock.release()
|
||||||
|
|
||||||
If you don't want to wait forever, you might try::
|
If you don't want to wait forever, you might try::
|
||||||
|
@ -251,7 +251,7 @@ If you don't want to wait forever, you might try::
|
||||||
except LockTimeout:
|
except LockTimeout:
|
||||||
lock.break_lock()
|
lock.break_lock()
|
||||||
lock.acquire()
|
lock.acquire()
|
||||||
print "I locked", lock.path
|
print("I locked", lock.path)
|
||||||
lock.release()
|
lock.release()
|
||||||
|
|
||||||
You can also insure that a lock is always held when appropriately decorated
|
You can also insure that a lock is always held when appropriately decorated
|
||||||
|
|
|
@ -12,23 +12,23 @@ Usage:
|
||||||
>>> try:
|
>>> try:
|
||||||
... lock.acquire()
|
... lock.acquire()
|
||||||
... except AlreadyLocked:
|
... except AlreadyLocked:
|
||||||
... print 'somefile', 'is locked already.'
|
... print('somefile', "is locked already.")
|
||||||
... except LockFailed:
|
... except LockFailed:
|
||||||
... print 'somefile', 'can\\'t be locked.'
|
... print('somefile', "can't be locked.")
|
||||||
... else:
|
... else:
|
||||||
... print 'got lock'
|
... print("got lock")
|
||||||
got lock
|
got lock
|
||||||
>>> print lock.is_locked()
|
>>> lock.is_locked()
|
||||||
True
|
True
|
||||||
>>> lock.release()
|
>>> lock.release()
|
||||||
|
|
||||||
>>> lock = LockFile('somefile')
|
>>> lock = LockFile('somefile')
|
||||||
>>> print lock.is_locked()
|
>>> lock.is_locked()
|
||||||
False
|
False
|
||||||
>>> with lock:
|
>>> with lock:
|
||||||
... print lock.is_locked()
|
... lock.is_locked()
|
||||||
True
|
True
|
||||||
>>> print lock.is_locked()
|
>>> lock.is_locked()
|
||||||
False
|
False
|
||||||
|
|
||||||
>>> lock = LockFile('somefile')
|
>>> lock = LockFile('somefile')
|
||||||
|
@ -37,7 +37,7 @@ False
|
||||||
... lock.acquire()
|
... lock.acquire()
|
||||||
...
|
...
|
||||||
>>> # Though no counter is kept, so you can't unlock multiple times...
|
>>> # Though no counter is kept, so you can't unlock multiple times...
|
||||||
>>> print lock.is_locked()
|
>>> lock.is_locked()
|
||||||
False
|
False
|
||||||
|
|
||||||
Exceptions:
|
Exceptions:
|
||||||
|
|
Loading…
Reference in New Issue