[Patches] [ python-Patches-541694 ] whichdb unittest
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 16 Apr 2002 05:46:21 -0700
Patches item #541694, was opened at 2002-04-09 15:15
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=541694&group_id=5470
Category: Tests
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gregory H. Ball (greg_ball)
Assigned to: Neal Norwitz (nnorwitz)
Summary: whichdb unittest
Initial Comment:
Attached patch is a first crack at a unit test for
whichdb.
I think that all functionality required for use by the
anydbm module is tested, but only for the
database modules found in a given installation.
The test case is built up at runtime to cover all the
available modules, so it is a bit introspective,
but I think it is obvious that it should run correctly.
Unfortunately it crashes on my box (Redhat 6.2) and
this seems to be a real problem with whichdb:
it assumes things about the dbm format which turn out
to be wrong sometimes.
I only discovered this because test_anydbm was
crashing,
when whichdb failed to work on dbm files. It would not
have crashed if dbhash was available... and dbhash was
not available
because bsddb was not built correctly. So I think
there is a build bug there, but I have little idea how
to solve that one at this
point.
Would I be correct in thinking that if this test really
uncovers bugs in whichdb, it can't be checked in until
they are fixed? Unfortunately I don't know much about
the various
databases, but I'll try to work with someone on it.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-16 08:46
Message:
Logged In: YES
user_id=6380
Greg, you assigned this to Neal Norwitz. Why? Usually bug
reports stay unassigned until a developer shows interest. I
doubt that this is Neal's kind of bug: he's not commented on
the bug report, nor does this match the other bugs that he's
interested in.
----------------------------------------------------------------------
Comment By: Gregory H. Ball (greg_ball)
Date: 2002-04-15 23:49
Message:
Logged In: YES
user_id=11365
More detail... the failure mode of test_anydbm is that
a database freshly created with anydbm.open() can't be
reopened using the 'r' mode.
Since whichdb returns None we wind up at
raise error, "need 'c' or 'n' flag to open new db"
Of course, whichdb is to blame for this.
----------------------------------------------------------------------
Comment By: Gregory H. Ball (greg_ball)
Date: 2002-04-15 23:41
Message:
Logged In: YES
user_id=11365
I get two failures...
First, using the dbm module as the engine, whichdb fails
to indentify the type. This is apparently a platform
problem... whichdbm.py has the comment
# Check for dbm first -- this has a .pag and a .dir file
but on my system the dbm modules creates a .db file.
The 'file' utility says
duh.db: Berkeley DB 2.X Hash/Little Endian (Version 5,
Logical sequence number:
file - 0, offset - 0, Bucket Size 4096, Overflow Point 1,
Last Freed 0, Max Bucket 1, High Mask 0x1, Low Mask 0x0,
Fill Factor 40, Number of Keys 0)
Now, a very simple patch would be to look for .db files
and call them 'dbm'. I have no idea though whether there
might be other database formats which use this extension.
So the thing to do might be to look for .db files and test
their magic. Actually, the .db files are identified as
"dbhash" databases if named explicitly to whichdb...
But the dbhash module isn't available due to missing bsddb!
I'm not sure what to make of all this.
I could just assume .db files with dbhash magic are always
of kind dbm... sound reasonable?
Secondly, dumbdbm doesn't work either, if the database is
empty... f.read(1) in ["'", '"'] doesn't turn out to be
true, since the .dir file is empty.
Ok, I've attached a naive patch. Note I'm not even
looking at testing dbhash or gdbm since they're not built
on my system. On the other hand since anydbm tries these
first, maybe they are effectively tested by test_anydbm.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-14 21:10
Message:
Logged In: YES
user_id=6380
What kind of crash do you experience?
Do you have a patch that fixes whichdb?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=541694&group_id=5470