I'm a contributor to Arcade, the Python 3.6+ 2d game library. I'm 
converting the existing doctests to pytest and trying to introduce some 
faster unit testing. In particular, not firing up a GUI window on each test.

I had hoped to make a MockWindow that I used to stub 
pyglet.window.BaseWindow. The challenge: this line:

from pyglet.window import Window

...immediately triggers a GUI window. Here are the last three lines in 
pyglet.window.__init__.py:

# XXX remove
# Create shadow window. (trickery is for circular import)
if not _is_pyglet_docgen:
    pyglet.window = sys.modules[__name__]
    gl._create_shadow_window()


The last line is done with non-import trickery that appears beyond the 
reach of mocking. Thus, I'm interested in some feedback:

- Am I totally on the wrong path, and unit testing a method on a subclass 
of BaseWindow requires a window?

- Should I refactor arcade.Window to subclass from something which 
subclasses BaseWindow, to give me a place to step in?

- Does anybody have a pyglet application with tests that don't spawn 
windows?

Thanks, and I confess that it is likely I am looking at this all wrong.

--Paul

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To post to this group, send email to pyglet-users@googlegroups.com.
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to