Re: doctest failures
Toshio Kuratomi <[email protected]> Tue, 02 Dec 2008 15:18:22 -0800
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
Toshio Kuratomi wrote: > Running the test suite on python-2.5.2 Fedora Linux has come up with > some doctest failures due to ordering. The set related tests won't > guarantee that they return values in a specific order so the tests can > fail. I'm attaching a patch that fixes the tests that have been failing > for us. You might want to audit the doctests to make sure there aren't > other checks that depend on a particular order being returned from a > set, though. > Here's a new patch after building with python-2.6 and getting more failures. -Toshio _______________________________________________ PEAK mailing list [email protected] http://www.eby-sarna.com/mailman/listinfo/peak
python-peak-rules-doctest.patch
(text/x-patch, 3.8 KB)
Index: PEAK-Rules-0.5a1.dev-r2582/Criteria.txt
===================================================================
--- PEAK-Rules-0.5a1.dev-r2582.orig/Criteria.txt
+++ PEAK-Rules-0.5a1.dev-r2582/Criteria.txt
@@ -302,8 +302,8 @@ of intersecting them will be a conjuncti
>>> intersect(float, MySet([int, str]))
MySet([<type 'float'>, <type 'int'>, <type 'str'>])
- >>> intersect(MySet([d, c]), MySet([int, str]))
- MySet([<class 'd'>, <class ...c...>, <type 'str'>])
+ >>> intersect(MySet([d, c]), MySet([int, str])) == MySet([d, c, str])
+ True
If you want to ensure that all items in a set are of appropriate type or value,
you can override ``__init__`` to do the checking, and raise an appropriate
@@ -462,13 +462,15 @@ contents. In other words::
... ])
True
- >>> intersect(int_or_str, Conjunction([long, float]))
- DisjunctionSet([Conjunction([<type 'int'>, <type 'long'>, <type 'float'>]),
- Conjunction([<type 'str'>, <type 'long'>, <type 'float'>])])
-
- >>> intersect(Conjunction([int, str]), long_or_float)
- DisjunctionSet([Conjunction([<type 'int'>, <type 'str'>, <type 'long'>]),
- Conjunction([<type 'int'>, <type 'str'>, <type 'float'>])])
+ >>> intersect(int_or_str, Conjunction([long, float])) == DisjunctionSet([
+ ... Conjunction([int, long, float]), Conjunction([str, long, float])
+ ... ])
+ True
+
+ >>> intersect(Conjunction([int, str]), long_or_float) == DisjunctionSet([
+ ... Conjunction([int, str, long]), Conjunction([int, str, float])
+ ... ])
+ True
As you can see, this is the heart of the process that allows expressions like
``(A or B) and (C or D)`` to be transformed into their disjunctive normal
@@ -974,8 +976,10 @@ will be AST-like structures.)
Creating a test with disjunct criteria actually returns a set of tests::
- >>> Test("x", DisjunctionSet([int, str]))
- DisjunctionSet([Test('x', <type 'int'>), Test('x', <type 'str'>)])
+ >>> Test("x", DisjunctionSet([int, str])) == DisjunctionSet([
+ ... Test('x', str), Test('x', int)
+ ... ])
+ True
So the ``disjuncts()`` of a test will always just be the test itself::
@@ -995,9 +999,10 @@ a disjunction of tests::
... Test('x',
... NotObjects([IsObject('foo',False), IsObject('bar',False)])
... )
- ... )
- DisjunctionSet([Test('x', IsObject('foo', True)),
- Test('x', IsObject('bar', True))])
+ ... ) == DisjunctionSet([Test('x', IsObject('foo', True)),
+ ... Test('x', IsObject('bar', True))
+ ... ])
+ True
Intersecting two tests for the same dispatch expression returns a test whose
criterion is the intersection of the original tests' criteria::
Index: PEAK-Rules-0.5a1.dev-r2582/Indexing.txt
===================================================================
--- PEAK-Rules-0.5a1.dev-r2582.orig/Indexing.txt
+++ PEAK-Rules-0.5a1.dev-r2582/Indexing.txt
@@ -1083,6 +1083,7 @@ Value Map Generation
--------------------
>>> from peak.rules.indexing import split_ranges
+ >>> from peak.util.extremes import Min, Max
>>> def dump_ranges(ind, cases):
... exact, ranges = split_ranges(*ind.seed_bits(cases))
@@ -1104,12 +1105,14 @@ Value Map Generation
({}, [((Min, Max), [])])
>>> ind.add_case(0, Value(19))
- >>> dump_ranges(ind, ind.known_cases)
- ({Min: [], 19: [0]}, [((Min, Max), [])])
+ >>> result = dump_ranges(ind, ind.known_cases)
+ >>> result == ({Min: [], 19: [0]}, [((Min, Max), [])])
+ True
>>> ind.add_case(1, Value(23))
- >>> dump_ranges(ind, ind.known_cases)
- ({Min: [], 19: [0], 23: [1]}, [((Min, Max), [])])
+ >>> result = dump_ranges(ind, ind.known_cases)
+ >>> result == ({Min: [], 19: [0], 23: [1]}, [((Min, Max), [])])
+ True
>>> ind.add_case(2, Value(23, False))
>>> dump_ranges(ind, ind.known_cases)
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkk1wj8ACgkQX6yAic2E7kgaFgCfdpIgt4Sxx6oCDPBfEo7oESjE A8kAn1aGAebZVYd+e+xhF58/Xqtsn5YJ =OzGM -----END PGP SIGNATURE-----