Skip to content

Commit e4ad57b

Browse files
authored
Merge pull request #5 from nlgio/master
Fix dumpObjectStore to dump objects in a consistent order
2 parents f8420e6 + 1c9f135 commit e4ad57b

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

MiddleKit/Run/SQLObjectStore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def dumpKlassIds(self, out=None):
719719
def dumpObjectStore(self, out=None, progress=False):
720720
if out is None:
721721
out = sys.stdout
722-
for klass in self.model().klasses().values():
722+
for klass in sorted( self.model().klasses().values(), key=lambda a:a.name()):
723723
if progress:
724724
sys.stderr.write(".")
725725
out.write('%s objects\n' % (klass.name()))

MiddleKit/Tests/MKDump.mkmodel/Samples.csv

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Bar objects
22
barNonstandardId,name
33
3,string containing spaces
44

5+
Baz objects
6+
bazNonstandardId,name,priority
7+
4,"string containing 'lots'' of ""quotes""
8+
and a newline and a tab",10
9+
510
Foo objects
611
fooNonstandardId,text,bar,fruit,num,isValid
712
5,hello,Bar.3,apple,5,1
813
6,,Baz.4,banana,,0
914
7,,,banana,,0
1015

11-
Baz objects
12-
bazNonstandardId,name,priority
13-
4,"string containing 'lots'' of ""quotes""
14-
and a newline and a tab",10
15-
1616

MiddleKit/Tests/MKDump.mkmodel/TestSamples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ def test(store):
44
with open('Dump.csv', 'w') as samples:
55
store.dumpObjectStore(samples)
66

7-
command = 'diff -u ../MKDump.mkmodel/Samples.csv Dump.csv'
7+
command = 'diff -uZ ../MKDump.mkmodel/Samples.csv Dump.csv'
88
print command
99
retval = os.system(command)
10-
retval >>= 8 # upper byte is the return code
10+
if os.name=='posix':
11+
retval >>= 8 # upper byte is the return code
1112

1213
assert retval == 0

0 commit comments

Comments
 (0)