diff --git a/test_xvfb.py b/test_xvfb.py index aa0420e..f8b19a1 100644 --- a/test_xvfb.py +++ b/test_xvfb.py @@ -64,7 +64,7 @@ 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() @@ -72,6 +72,14 @@ def test_start_with_arbitrary_kwargs(self): 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): diff --git a/xvfbwrapper.py b/xvfbwrapper.py index a2ad782..72fbecf 100644 --- a/xvfbwrapper.py +++ b/xvfbwrapper.py @@ -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]