import atexit
import os

_xvfb = None

def start_xvfb():
  from xvfbwrapper import Xvfb
  global _xvfb
  if "DISPLAY" in os.environ:
    del os.environ["DISPLAY"]
  _xvfb = Xvfb()
  _xvfb.start()
  atexit.register(_xvfb.stop)

def stop_xvfb():
  global _xvfb
  _xvfb.stop()

import atexit
import os

_xvfb = None


def start_xvfb():
    from xvfbwrapper import Xvfb
    global _xvfb
    _xvfb = Xvfb()
    _xvfb.start()
    atexit.register(_xvfb.stop)


def stop_xvfb():
    global _xvfb
    _xvfb.stop()

Remove removal of DISPLAY environment variable
Remove removal of DISPLAY environment variable

The issue has to do with the two lines:

` if "DISPLAY" in os.environ:
    del os.environ["DISPLAY"]`

This seems to remove the DISPLAY environment variable unnecessarily, as on line 50 of xvfbwrapper.py, self.orig_display is set to the value of DISPLAY. self.orig_display is checked on line 83, which is where the error occurs. Because of xvfb.py removing the environment variable and self.orig_display being set to the original value, on line 84 when it tries to remove DISPLAY, it has already been removed by xvfb.py, so it throws a KeyError.
  import atexit
  import os
  
  _xvfb = None
  
+ 
  def start_xvfb():
-   from xvfbwrapper import Xvfb
+     from xvfbwrapper import Xvfb
-   global _xvfb
+     global _xvfb
-   if "DISPLAY" in os.environ:
-     del os.environ["DISPLAY"]
-   _xvfb = Xvfb()
+     _xvfb = Xvfb()
-   _xvfb.start()
+     _xvfb.start()
-   atexit.register(_xvfb.stop)
+     atexit.register(_xvfb.stop)
+ 
  
  def stop_xvfb():
-   global _xvfb
+     global _xvfb
-   _xvfb.stop()
+     _xvfb.stop()
  
Remove removal of DISPLAY environment variable
## Code Before:
import atexit
import os

_xvfb = None

def start_xvfb():
  from xvfbwrapper import Xvfb
  global _xvfb
  if "DISPLAY" in os.environ:
    del os.environ["DISPLAY"]
  _xvfb = Xvfb()
  _xvfb.start()
  atexit.register(_xvfb.stop)

def stop_xvfb():
  global _xvfb
  _xvfb.stop()

## Instruction:
Remove removal of DISPLAY environment variable
## Code After:
import atexit
import os

_xvfb = None


def start_xvfb():
    from xvfbwrapper import Xvfb
    global _xvfb
    _xvfb = Xvfb()
    _xvfb.start()
    atexit.register(_xvfb.stop)


def stop_xvfb():
    global _xvfb
    _xvfb.stop()
