[PATCH] fix for doctest paths on windows
Fredrik Lundh
fredrik at pythonware.com
Sat Apr 16 09:53:30 BST 2005
here's a trivial patch that fixes some doctest issues on windows. I still
have problems with "\r" creeping into file identifiers; more on that later.
enjoy! /F
--- bzrlib/inventory.py.bak Sat Apr 16 10:47:28 2005
+++ bzrlib/inventory.py Sat Apr 16 10:47:57 2005
@@ -23,9 +23,13 @@
ROOT_ID = "TREE_ROOT"
-import sys, os.path, types, re
+import sys, os, types, re
from sets import Set
+def path(s):
+ # helper to "normalize" path names
+ return s.replace(os.sep, '/')
+
try:
from cElementTree import Element, ElementTree, SubElement
except ImportError:
@@ -64,8 +68,8 @@
'TREE_ROOT'
>>> i.add(InventoryEntry('123', 'src', 'directory', ROOT_ID))
>>> i.add(InventoryEntry('2323', 'hello.c', 'file', parent_id='123'))
- >>> for j in i.iter_entries():
- ... print j
+ >>> for f, e in i.iter_entries():
+ ... print (path(f), e)
...
('src', InventoryEntry('123', 'src', kind='directory', parent_id='TREE_ROOT'))
('src/hello.c', InventoryEntry('2323', 'hello.c', kind='file', parent_id='123'))
@@ -83,7 +87,7 @@
>>> i['2326']
InventoryEntry('2326', 'wibble.c', kind='file', parent_id='2325')
>>> for j in i.iter_entries():
- ... print j[0]
+ ... print path(j[0])
... assert i.path2id(j[0])
...
src
@@ -91,7 +95,7 @@
src/hello.c
src/wibble
src/wibble/wibble.c
- >>> i.id2path('2326')
+ >>> path(i.id2path('2326'))
'src/wibble/wibble.c'
TODO: Maybe also keep the full path of the entry, and the children?
--- bzrlib/tests.py.bak Sat Apr 16 10:47:37 2005
+++ bzrlib/tests.py Sat Apr 16 10:48:05 2005
@@ -15,12 +15,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
# XXX: We might prefer these to be in a text file rather than Python
# source, but that only works in doctest from Python 2.4 and later,
# which is not present in Warty.
+import os
+
+def path(s):
+ # helper to "normalize" path names
+ return s.replace(os.sep, '/')
+
r"""
Bazaar-NG test cases
********************
@@ -160,19 +164,19 @@
Adding a directory, and we see the file underneath:
>>> b.add('d1')
- >>> [v[0] for v in b.inventory.directories()]
+ >>> [path(v[0]) for v in b.inventory.directories()]
['', 'd1']
- >>> list(b.working_tree().unknowns())
+ >>> [path(v) for v in b.working_tree().unknowns()]
['d2', 'd1/f1']
>>> # d2 comes first because it's in the top directory
>>> b.add('d2')
>>> b.commit('add some stuff')
- >>> list(b.working_tree().unknowns())
+ >>> [path(v) for v in b.working_tree().unknowns()]
['d1/f1', 'd2/d3', 'd2/f2', 'd2/f3']
>>> b.add('d1/f1')
- >>> list(b.working_tree().unknowns())
+ >>> [path(v) for v in b.working_tree().unknowns()]
['d2/d3', 'd2/f2', 'd2/f3']
Tests for ignored files and patterns:
More information about the bazaar
mailing list