Yes, writing cross platform doctests is a bit of an art (C Python 2 vs 3 vs PyPy vs Jython etc).

It does get easier with practise, but this is one reason why we put most tests in as unittests, and keep the doctests primarily as documentation examples.