Merge pull request #9 from cgoldberg/new-stuff

drop python 2.6 support and other fixes
This commit is contained in:
Corey Goldberg 2015-12-09 05:31:28 -08:00
commit 694fe897e9
4 changed files with 16 additions and 24 deletions

View File

@ -1,12 +1,12 @@
language: python language: python
python: python:
- "2.6"
- "2.7" - "2.7"
- "3.2" - "3.2"
- "3.3" - "3.3"
- "3.4" - "3.4"
- "3.5" - "3.5"
before_install: before_install:
- sudo apt-get update -qq - "sudo apt-get update -qq"
- sudo apt-get install -y xvfb - "sudo apt-get install -y xvfb"
script: nosetests script:
- "python -m unittest discover"

View File

@ -2,6 +2,8 @@
xvfbwrapper xvfbwrapper
=============== ===============
https://travis-ci.org/cgoldberg/xvfbwrapper.svg?branch=master
Python wrapper for running a display inside X virtual framebuffer (Xvfb). This is useful for running acceptance tests (i.e. browser-based tests) on a headless server. Python wrapper for running a display inside X virtual framebuffer (Xvfb). This is useful for running acceptance tests (i.e. browser-based tests) on a headless server.
* Dev: https://github.com/cgoldberg/xvfbwrapper * Dev: https://github.com/cgoldberg/xvfbwrapper
@ -24,7 +26,7 @@ Install xvfbwrapper from PyPI::
*********************** ***********************
* Xvfb (`sudo apt-get install xvfb`, or similar) * Xvfb (`sudo apt-get install xvfb`, or similar)
* Python 2.7 or 3.2+ (tested on py27, py32, py33, py34, pypy) * Python 2.7 or 3.2+ (tested on py27, py32, py33, py34, 3.5, pypy)
************************************** **************************************
About Xvfb (X Virtual Framebuffer) About Xvfb (X Virtual Framebuffer)
@ -108,7 +110,7 @@ In the X Window System, Xvfb or X Virtual FrameBuffer is an X11 server that perf
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(verbosity=2) unittest.main(verbosity=2)
This code uses `selenium` and `xvfbwrapper` to run a test with Firefox inside a headless display. This above code uses `selenium` and `xvfbwrapper` to run a test with Firefox inside a headless display. It will:
* install selenium bindings: `pip install selenium` * install selenium bindings: `pip install selenium`
* Firefox will launch inside virtual display (headless) * Firefox will launch inside virtual display (headless)

17
tox.ini
View File

@ -4,20 +4,11 @@
# and then run "tox" from this directory. # and then run "tox" from this directory.
[tox] [tox]
envlist = flake8, py27, py32, py33, py34, pypy envlist=flake8,py27,py32,py33,py34,py35,pypy
[flake8]
exclude = .tox, build
[testenv] [testenv]
deps = commands={envpython} -m unittest discover
nose
commands =
{envpython} setup.py install
nosetests -v
[testenv:flake8] [testenv:flake8]
deps = deps=flake8
flake8 commands=flake8
commands =
flake8

View File

@ -47,11 +47,10 @@ class Xvfb:
def start(self): def start(self):
self.vdisplay_num = self.search_for_free_display() self.vdisplay_num = self.search_for_free_display()
self.xvfb_cmd = ['Xvfb', ':%d' % self.vdisplay_num] + self.xvfb_cmd self.xvfb_cmd = ['Xvfb', ':%d' % self.vdisplay_num] + self.xvfb_cmd
with open(os.devnull, 'w') as fnull:
self.proc = subprocess.Popen(self.xvfb_cmd, self.proc = subprocess.Popen(self.xvfb_cmd,
stdout=open(os.devnull), stdout=fnull,
stderr=open(os.devnull), stderr=fnull)
)
time.sleep(0.2) # give Xvfb time to start time.sleep(0.2) # give Xvfb time to start
ret_code = self.proc.poll() ret_code = self.proc.poll()
if ret_code is None: if ret_code is None: