diff --git a/README.rst b/README.rst index b3860c1..337f5e2 100644 --- a/README.rst +++ b/README.rst @@ -23,7 +23,7 @@ Install xvfbwrapper from PyPI *********************** * Xvfb (`sudo apt-get install xvfb`, or similar) -* Python 2 +* Python 2.7 or 3.2+ (tested on py27, py32, py33, pypy) ************************************** About Xvfb (X Virtual Framebuffer) @@ -53,34 +53,30 @@ In the X Window System, Xvfb or X virtual framebuffer is an X11 server that perf :: - #!/usr/bin/env python - from selenium import webdriver from xvfbwrapper import Xvfb - + import unittest - class TestHomepages(unittest.TestCase): - + class TestPages(unittest.TestCase): + def setUp(self): - self.vdisplay = Xvfb(width=1280, height=720) - self.vdisplay.start() + self.xvfb = Xvfb(width=1280, height=720) + self.addCleanup(self.xvfb.stop) + self.xvfb.start() self.browser = webdriver.Firefox() - + self.addCleanup(self.browser.quit) + def testUbuntuHomepage(self): self.browser.get('http://www.ubuntu.com') self.assertIn('Ubuntu', self.browser.title) - + def testGoogleHomepage(self): self.browser.get('http://www.google.com') self.assertIn('Google', self.browser.title) - - def tearDown(self): - self.browser.quit() - self.vdisplay.stop() - - + + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/xvfbwrapper/test_xvfb.py b/xvfbwrapper/test_xvfb.py index 709ebb6..bce1b8e 100644 --- a/xvfbwrapper/test_xvfb.py +++ b/xvfbwrapper/test_xvfb.py @@ -21,6 +21,7 @@ class TestXvfb(unittest.TestCase): h = 600 depth = 16 xvfb = Xvfb(width=w, height=h, colordepth=depth) + self.addCleanup(xvfb.stop) xvfb.start() self.assertEqual(w, xvfb.width) self.assertEqual(h, xvfb.height)