'tests that environments variables that we pass into sh commands
exist in the environment, and on the sh module'

def test_environment(self):

    import os
    env = {'HERP': 'DERP'}
    osx_cruft = ['__CF_USER_TEXT_ENCODING', '__PYVENV_LAUNCHER__', 'VERSIONER_PYTHON_PREFER_32_BIT', 'VERSIONER_PYTHON_VERSION']
    py = create_tmp_test(('\nimport    os\n\nosx_cruft    =    %s\nfor    key    in    osx_cruft:\n                try:    del    os.environ[key]\n                except:    pass\nprint(os.environ["HERP"]    +    "    "    +    str(len(os.environ)))\n' % osx_cruft))
    out = python(py.name, _env=env).strip()
    self.assertEqual(out, 'DERP    1')
    py = create_tmp_test(('\nimport    os,    sys\nsys.path.insert(0,    os.getcwd())\nimport    sh\nosx_cruft    =    %s\nfor    key    in    osx_cruft:\n                try:    del    os.environ[key]\n                except:    pass\nprint(sh.HERP    +    "    "    +    str(len(os.environ)))\n' % osx_cruft))
    out = python(py.name, _env=env, _cwd=THIS_DIR).strip()
    self.assertEqual(out, 'DERP    1')
