libtcod / python-tcod

A high-performance Python port of libtcod. Includes the libtcodpy module for backwards compatibility with older projects.
BSD 2-Clause "Simplified" License
413 stars 36 forks source link

Mock init for testing? #25

Closed micaiahparker closed 7 years ago

micaiahparker commented 7 years ago

I'm writing a simple wrapper for python-tdl and for testing it would be handy to have a version of tdl.init that doesn't print to the console or open a window. If you don't have the desire or time to implement something like this then I would be willing to look into it if you pointed me in the right direction. I'm thinking something like

console = tdl.init(width, height, title, debug=False)

HexDecimal commented 7 years ago

The terminal output and window are annoying, but they won't mess up unit tests.

With recent versions of libtcod-cffi you can create new consoles without creating a root console first. I just need to remove what are now unnecessary checks from tdl. Some functions like tdl.flush, tdl.set_title, and tdl.set_fullscreen are still going to complain if the root console is missing, but you'll be able to work on Console and Window objects. Would this be enough?

python-tdl is itself not an efficient wrapper over libtcod, so I'm worried that anything wrapping it will inherit its performance issues. I'd recommend that you wrapped libtcod-cffi instead, if that's possible.

What kind of wrapper are you making? I might have more specific advice.

micaiahparker commented 7 years ago

That would certainly be enough, thanks!