doctest failures
Toshio Kuratomi <[email protected]> Tue, 02 Dec 2008 14:06:42 -0800
| Newsgroups | gmane.comp.python.peak |
|---|---|
| Message-ID | <[email protected]> |
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. -Toshio _______________________________________________ PEAK mailing list [email protected] http://www.eby-sarna.com/mailman/listinfo/peak
python-peak-rules-doctest.patch
(text/x-patch, 3.1 KB)
diff -up PEAK-Rules-0.5a1.dev-r2581/Criteria.txt.test PEAK-Rules-0.5a1.dev-r2581/Criteria.txt
--- PEAK-Rules-0.5a1.dev-r2581/Criteria.txt.test 2008-12-02 12:47:12.000000000 -0800
+++ PEAK-Rules-0.5a1.dev-r2581/Criteria.txt 2008-12-02 12:53:14.000000000 -0800
@@ -302,8 +302,9 @@ 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'>])
+ >>> result = intersect(MySet([d, c]), MySet([int, str]))
+ >>> result == 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
@@ -974,8 +975,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'>)])
+ >>> result = Test("x", DisjunctionSet([int, str]))
+ >>> result == DisjunctionSet([Test('x', str),
+ ... Test('x', int)])
+ True
So the ``disjuncts()`` of a test will always just be the test itself::
@@ -991,13 +994,14 @@ intact::
But if the test criterion is a conjunction or range, negating it can produce
a disjunction of tests::
- >>> negate(
+ >>> result = negate(
... Test('x',
... NotObjects([IsObject('foo',False), IsObject('bar',False)])
... )
... )
- DisjunctionSet([Test('x', IsObject('foo', True)),
- Test('x', IsObject('bar', True))])
+ >>> result == 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::
diff -up PEAK-Rules-0.5a1.dev-r2581/Indexing.txt.test PEAK-Rules-0.5a1.dev-r2581/Indexing.txt
--- PEAK-Rules-0.5a1.dev-r2581/Indexing.txt.test 2008-12-02 12:53:33.000000000 -0800
+++ PEAK-Rules-0.5a1.dev-r2581/Indexing.txt 2008-12-02 13:29:28.000000000 -0800
@@ -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) iEYEARECAAYFAkk1sXIACgkQX6yAic2E7kjoRwCfVtuS6sHr8eN8BhYQv1RrelFG RRwAn0BS8MdHQO5ZxkaJg9KmciWSxNDE =CvJt -----END PGP SIGNATURE-----