Skip to content

Commit f9993e8

Browse files
committed
Better interface for RecordFields and improved tests.
1 parent 77bca11 commit f9993e8

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/dist/
66
/pxpy.so
77
/*.egg-info/
8+
/*.egg/

pxpy.pyx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ cdef class Table:
8181
def getTableName(self):
8282
return self.doc.getTableName()
8383

84-
def getCodePage(self):
85-
"""
86-
Return the code page of the underlying Paradox table.
87-
"""
88-
return self.doc.getCodePage()
89-
9084
def getTargetEncoding(self):
9185
return self.doc.targetEncoding
9286

@@ -358,7 +352,6 @@ cdef class ParadoxField:
358352
cdef readonly flen
359353

360354
def __cinit__(self, *args):
361-
#print 'ParadoxField cinit', args
362355
pass
363356

364357
def _init_fields(self, fname, int ftype, int flen):
@@ -427,6 +420,14 @@ cdef class RecordField(ParadoxField):
427420
def __unicode__(self):
428421
return self.getValue()
429422

423+
def getName(self):
424+
return self.fname
425+
name = property(getName)
426+
427+
def getType(self):
428+
return self.ftype
429+
type = property(getType)
430+
430431
def getValue(self):
431432
"""
432433
Get the field's value.
@@ -563,7 +564,7 @@ cdef class RecordField(ParadoxField):
563564
pass
564565
elif self.ftype == pxfNumTypes:
565566
pass
566-
567+
value = property(getValue)
567568

568569
cdef class Record:
569570
"""

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def run(self):
5151
],
5252
zip_safe=False,
5353
setup_requires=["Cython>=0.13"],
54+
tests_require=["unittest2==0.5.1"],
5455
ext_modules=[
5556
Extension('pxpy', ['pxpy.pyx'],
5657
libraries=['px']),

tests/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# :Revision: $Revision: 1.2 $ by $Author: lele $
88
# :Date: $Date: 2004/07/19 14:38:04 $
99
#
10-
import unittest
10+
import unittest2 as unittest
1111
import os.path
1212
import pxpy
1313

@@ -56,9 +56,19 @@ def test_blob_file(self):
5656
table.open()
5757
table.setBlobFile(os.path.join(FIXTURE_DIR, 'KOMMENT.MB'))
5858

59+
baptistene = table[0]
60+
field = baptistene[0]
61+
self.assertEqual(field.name, u"Aar")
62+
self.assertEqual(field.value, u"2006")
63+
self.assertEqual(field.type, 1)
64+
65+
self.assertEqual(baptistene[1].value, u"BAPTI")
66+
self.assertRegexpMatches(baptistene[3].value, r"^Statistikken inkluderer")
67+
68+
5969
for record in table:
60-
for field in record:
61-
print field
70+
self.assertNotEqual(record[3], "[MISSING BLOB FILE]")
71+
6272

6373
table.close()
6474

0 commit comments

Comments
 (0)