O'Reilly logo

Python Testing Beginner's Guide by Daniel Arbuckle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - using ellipsis in tests

We'll use the ellipsis in a few different tests, to get a better feel for what it does and how to use it.

  1. Insert the following text into your doctest file:
    Next up, we're exploring the ellipsis.
    >>> sys.modules # doctest: +ELLIPSIS
    {...'sys': <module 'sys' (built-in)>...}
    >>> 'This is an expression that evaluates to a string'
    ... # doctest: +ELLIPSIS
    'This is ... a string'
    >>> 'This is also a string' # doctest: +ELLIPSIS
    'This is ... a string'
    >>> import datetime
    >>> datetime.datetime.now().isoformat() # doctest: +ELLIPSIS
    '...-...-...T...:...:...'
    
  2. Run the tests using doctest and the following screen is displayed:.
  3. None of these tests would pass without the ellipsis. Think about that, and then try making ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required