diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-19 22:37:40 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-05-19 22:37:40 -0400 |
commit | 28c5207103c91950079cbe58ac6b7455af351d49 (patch) | |
tree | 1b131e158a8f52f89436001707a6a278ecf20444 | |
parent | 1ad68c6f3dee2d96f831e078dd7b58a4c39c08c4 (diff) | |
download | external_python_setuptools-28c5207103c91950079cbe58ac6b7455af351d49.tar.gz external_python_setuptools-28c5207103c91950079cbe58ac6b7455af351d49.tar.bz2 external_python_setuptools-28c5207103c91950079cbe58ac6b7455af351d49.zip |
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).
-rw-r--r-- | tests/api_tests.txt | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/api_tests.txt b/tests/api_tests.txt index b5574021..06e14a33 100644 --- a/tests/api_tests.txt +++ b/tests/api_tests.txt @@ -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 |