@pytest.fixture
def install_egg(modules_tmpdir, monkeypatch):
 def inner(name, base=modules_tmpdir):
  if (not isinstance(name, str)):
   raise ValueError(name)
  base.join(name).ensure_dir()
  base.join(name).join('__init__.py').ensure()
  egg_setup = base.join('setup.py')
  egg_setup.write(textwrap.dedent("\n        from setuptools import setup\n        setup(name='{0}',\n              version='1.0',\n              packages=['site_egg'],\n              zip_safe=True)\n        ".format(name)))
  import subprocess
  subprocess.check_call([sys.executable, 'setup.py', 'bdist_egg'], cwd=str(modules_tmpdir))
  (egg_path,) = modules_tmpdir.join('dist/').listdir()
  monkeypatch.syspath_prepend(str(egg_path))
  return egg_path
 return inner

@ pytest . fixture def install_egg ( modules_tmpdir , monkeypatch ) : def inner ( name , base = modules_tmpdir ) : if ( not isinstance ( name , str ) ) : raise ValueError ( name ) base . join ( name ) . ensure_dir ( ) base . join ( name ) . join ( '__init__.py' ) . ensure ( ) egg_setup = base . join ( 'setup.py' ) egg_setup . write ( textwrap . dedent ( "\n        from setuptools import setup\n        setup(name='{0}',\n              version='1.0',\n              packages=['site_egg'],\n              zip_safe=True)\n        " . format ( name ) ) ) import subprocess subprocess . check_call ( [ sys . executable , 'setup.py' , 'bdist_egg' ] , cwd = str ( modules_tmpdir ) ) ( egg_path , ) = modules_tmpdir . join ( 'dist/' ) . listdir ( ) monkeypatch . syspath_prepend ( str ( egg_path ) ) return egg_path return inner
generate egg from package name inside base and put the egg into sys .