Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Does anyone have a good way to write a doctest for draw_map() in dd_game.py?

I'm trying to work my way through writing doctests for the functions in dd_game.py, the dungeon game we used in the Python Testing course.

I've been playing around with it in the shell and can't seem to get it to print out in a way that makes sense.

This is how I thought I could write it:

def draw_map(cells):
    """Based on array of cell coordinates, draw a grid to the screen

    >>> draw_map([(0, 0), (1, 0), (0, 1), (1, 1)])
     _ _
    |_|_|
    |_|_|

    """

When I run the doctest I get this output:

**********************************************************************
File ".\dd_game.py", line 104, in dd_game.draw_map
Failed example:
    draw_map([(0, 0), (1, 0), (0, 1), (1, 1)])
Expected:
     _ _
    |_|_|
    |_|_|
Got:
     _ _ _ _ _
    |_|_|_|_
**********************************************************************
1 items had failures:
   1 of   1 in dd_game.draw_map
***Test Failed*** 1 failures.

I thought it could have something to do with the GAME_DIMENSIONS constant as it is in the function but playing around with it hasn't changed my output at all.

Any input would be appreciated!