()
| 83 | # Build decorator that uses the setup_environment/setup_environment |
| 84 | @pytest.fixture |
| 85 | def environment(): |
| 86 | global oldstuff, platformstuff |
| 87 | oldstuff = ( |
| 88 | env.copy(), |
| 89 | os.name, |
| 90 | sys.platform, |
| 91 | path.get_home_dir, |
| 92 | IPython.__file__, |
| 93 | os.getcwd(), |
| 94 | ) |
| 95 | |
| 96 | yield |
| 97 | |
| 98 | ( |
| 99 | oldenv, |
| 100 | os.name, |
| 101 | sys.platform, |
| 102 | path.get_home_dir, |
| 103 | IPython.__file__, |
| 104 | old_wd, |
| 105 | ) = oldstuff |
| 106 | os.chdir(old_wd) |
| 107 | reload(path) |
| 108 | |
| 109 | for key in list(env): |
| 110 | if key not in oldenv: |
| 111 | del env[key] |
| 112 | env.update(oldenv) |
| 113 | assert not hasattr(sys, "frozen") |
| 114 | |
| 115 | |
| 116 | with_environment = pytest.mark.usefixtures("environment") |