Commit 28c52071 authored by Jason R. Coombs's avatar Jason R. Coombs

Update doctest to use syntax suitable for Python 2 and Python 3. Credit to...

Update doctest to use syntax suitable for Python 2 and Python 3. Credit to Lennart Regebro for the [hints in his book](http://python3porting.com/problems.html#handling-expected-exceptions).
parent 1ad68c6f
......@@ -208,11 +208,14 @@ You can ask a WorkingSet to ``find()`` a distribution matching a requirement::
Note that asking for a conflicting version of a distribution already in a
working set triggers a ``pkg_resources.VersionConflict`` error:
>>> ws.find(Requirement.parse("Bar==1.0")) # doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
pkg_resources.VersionConflict: (Bar 0.9 (http://example.com/something),
Requirement.parse('Bar==1.0'))
>>> try:
... ws.find(Requirement.parse("Bar==1.0"))
... except pkg_resources.VersionConflict:
... exc = sys.exc_info()[1]
... print(str(exc))
... else:
... raise AssertionError("VersionConflict was not raised")
(Bar 0.9 (http://examples.com/something), Requirement.parse('Bar==1.0'))
You can subscribe a callback function to receive notifications whenever a new
distribution is added to a working set. The callback is immediately invoked
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment