astropy/astropy — pull request #197 by eteq (2012-04-09 06:11:16+00:00)
Title: fixes test helper to not import astropy.config if invoked from setup

Currently, running setup.py causes `astropy.config` to be imported, because it imports ``astropy/tests/helpers.py``, which uses `ConfigurationItem`. This is problematic for a few reasons - it means that anything in astropy.config has to be 2to3-independent, and it casues the ``~/.astropy`` to be created just for running ``setup.py``, which is neither intended nor expected behavior. This PR fixes these by just not using the `ConfigurationItem` trick if we are running inside ``setup.py``.

The configuration item can still be updated using the environment variable ASTROPY_USE_SYSTEM_PYTEST - once #48 is fixed, this should be updated to reflect whatever envar naming scheme is used there.

@mdboom, the solution here for knowing we are in ``setup.py`` is inspired by the way you dealt with ``is_in_build_mode``. I realize this seems redundant, given that `set_build_mode` is called in ``setup.py``, but the problem here is that ``setup_helpers.py`` *itself* imports the ``tests/helpers.py``. What do you think of this?