diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-03-12 15:32:27 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-03-13 14:15:13 -0400 |
commit | aeb8a5c5d6f102cea16c0bd5ab7fd2f9d3f4a203 (patch) | |
tree | 827113b788697a9e49c6a76e2f1ea9ddf05cdbdb | |
parent | 1bf1debce68d6196cad058b5a19d2c9a04233199 (diff) | |
download | pecan-aeb8a5c5d6f102cea16c0bd5ab7fd2f9d3f4a203.tar.gz |
Improved test cleanup for environment-variable-based configuration.
-rw-r--r-- | pecan/tests/test_conf.py | 10 | ||||
-rw-r--r-- | setup.py | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/pecan/tests/test_conf.py b/pecan/tests/test_conf.py index f063faf..36ce380 100644 --- a/pecan/tests/test_conf.py +++ b/pecan/tests/test_conf.py @@ -3,6 +3,8 @@ import sys from pecan.tests import PecanTestCase +from mock import patch + __here__ = os.path.dirname(__file__) @@ -294,7 +296,6 @@ class TestConfFromEnv(PecanTestCase): def setUp(self): super(TestConfFromEnv, self).setUp() self.conf_from_env = self.get_conf_from_env() - os.environ['PECAN_CONFIG'] = '' def tearDown(self): os.environ['PECAN_CONFIG'] = '' @@ -311,8 +312,8 @@ class TestConfFromEnv(PecanTestCase): assert issubclass(exc, error.__class__) assert error.message == msg + @patch.dict('os.environ', {'PECAN_CONFIG': '/'}) def test_invalid_path(self): - os.environ['PECAN_CONFIG'] = '/' msg = "PECAN_CONFIG was set to an invalid path: /" self.assertRaisesMessage(msg, RuntimeError, self.conf_from_env) @@ -321,7 +322,6 @@ class TestConfFromEnv(PecanTestCase): "no config file was passed as an argument." self.assertRaisesMessage(msg, RuntimeError, self.conf_from_env) + @patch.dict('os.environ', {'PECAN_CONFIG': os.path.abspath(__file__)}) def test_return_valid_path(self): - here = os.path.abspath(__file__) - os.environ['PECAN_CONFIG'] = here - assert self.conf_from_env() == here + assert self.conf_from_env() == os.path.abspath(__file__) @@ -32,7 +32,8 @@ tests_require = requirements + [ 'Genshi', 'Kajiki', 'Jinja2', - 'gunicorn' + 'gunicorn', + 'mock' ] if sys.version_info < (2, 7): tests_require += ['unittest2'] |