Browse Source

Merge pull request #4 from moschlar/contextmanager

Make Xvfb a contextmanager
changes/49/376949/1
Corey Goldberg 8 years ago
parent
commit
5dda044c72
  1. 7
      xvfbwrapper/xvfbwrapper.py

7
xvfbwrapper/xvfbwrapper.py

@ -37,6 +37,13 @@ class Xvfb:
else:
self.old_display_num = 0
def __enter__(self):
self.start()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.stop()
def start(self):
self.vdisplay_num = self.search_for_free_display()
self.xvfb_cmd = ['Xvfb', ':%d' % self.vdisplay_num] + self.xvfb_cmd

Loading…
Cancel
Save