Skip to content
Snippets Groups Projects
Commit dd0a62b7 authored by Alan De Smet's avatar Alan De Smet
Browse files

Fix doctests

parent 1261e6fa
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ class ExclusiveLockFile:
Can be used in a "with" block as a context manager.
>>> from exclusivelockfile import ExclusiveLockFile
>>> from csppfetch.exclusivelockfile import ExclusiveLockFile
>>> from tempfile import mkdtemp
>>> tmpdir = mkdtemp()
>>> filename = tmpdir+"/lock"
......@@ -134,14 +134,17 @@ def samefile(f1, f2):
False
>>> samefile(a.fileno(),a2.fileno())
True
>>> import os
>>> os.rename(tmpdir+"/a", tmpdir+"/c")
>>> samefile(a.fileno(),tmpdir+"/c")
True
>>> samefile(a.fileno(),tmpdir+"/a")
False
>>> import os
>>> os.unlink(tmpdir+"/a")
>>> a.close()
>>> b.close()
>>> a2.close()
>>> os.unlink(tmpdir+"/b")
>>> os.unlink(tmpdir+"/c")
>>> os.rmdir(tmpdir)
"""
try:
......@@ -178,6 +181,7 @@ def file_matches_filename(file, filename):
False
>>> file_matches_filename(a,tmpdir+"/missingfile")
False
>>> import os
>>> os.rename(tmpdir+"/a", tmpdir+"/c")
>>> c = open(tmpdir+"/c","w")
>>> newa = open(tmpdir+"/a","w")
......@@ -186,6 +190,10 @@ def file_matches_filename(file, filename):
>>> file_matches_filename(a,tmpdir+"/c")
True
>>> import os
>>> a.close()
>>> b.close()
>>> c.close()
>>> newa.close()
>>> os.unlink(tmpdir+"/a")
>>> os.unlink(tmpdir+"/b")
>>> os.unlink(tmpdir+"/c")
......@@ -208,7 +216,7 @@ def file_matches_filename(file, filename):
class AtomicCreateIfMissing:
""" Context manager to atomically create a file
>>> from exclusivelockfile import AtomicCreateIfMissing
>>> from csppfetch.exclusivelockfile import AtomicCreateIfMissing
>>> from tempfile import mkdtemp
>>> tmpdir = mkdtemp()
>>> filename = tmpdir+"/result"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment