Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for unary args #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion test_xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ def test_start_with_kwargs(self):
self.assertEqual(display_var, os.environ['DISPLAY'])
self.assertIsNotNone(xvfb.proc)

def test_start_with_arbitrary_kwargs(self):
def test_start_with_arbitrary_binary_kwargs(self):
xvfb = Xvfb(nolisten='tcp')
self.addCleanup(xvfb.stop)
xvfb.start()
display_var = ':{}'.format(xvfb.new_display)
self.assertEqual(display_var, os.environ['DISPLAY'])
self.assertIsNotNone(xvfb.proc)

def test_start_with_arbitrary_unary_kwargs(self):
xvfb = Xvfb(noreset=None)
self.addCleanup(xvfb.stop)
xvfb.start()
display_var = ':{}'.format(xvfb.new_display)
self.assertEqual(display_var, os.environ['DISPLAY'])
self.assertIsNotNone(xvfb.proc)

def test_start_fails_with_unknown_kwargs(self):
xvfb = Xvfb(foo='bar')
with self.assertRaises(RuntimeError):
Expand Down
5 changes: 4 additions & 1 deletion xvfbwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def __init__(self, width=800, height=680, colordepth=24, **kwargs):
self.width, self.height, self.colordepth)]

for key, value in kwargs.items():
self.extra_xvfb_args += ['-{}'.format(key), value]
if value:
self.extra_xvfb_args += ['-{}'.format(key), value]
else:
self.extra_xvfb_args.append('-{}'.format(key))

if 'DISPLAY' in os.environ:
self.orig_display = os.environ['DISPLAY'].split(':')[1]
Expand Down