diff options
-rw-r--r-- | .coveragerc | 1 | ||||
-rw-r--r-- | pecan/tests/config_fixtures/bad/syntaxerror.py | 2 | ||||
-rw-r--r-- | pecan/tests/test_conf.py | 20 |
3 files changed, 12 insertions, 11 deletions
diff --git a/.coveragerc b/.coveragerc index 9e39bc8..d1df824 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,2 @@ [run] source=pecan -omit=pecan/compat/dictconfig.py diff --git a/pecan/tests/config_fixtures/bad/syntaxerror.py b/pecan/tests/config_fixtures/bad/syntaxerror.py deleted file mode 100644 index 6ad0110..0000000 --- a/pecan/tests/config_fixtures/bad/syntaxerror.py +++ /dev/null @@ -1,2 +0,0 @@ -if false -var = 3 diff --git a/pecan/tests/test_conf.py b/pecan/tests/test_conf.py index e62da2c..c273b6f 100644 --- a/pecan/tests/test_conf.py +++ b/pecan/tests/test_conf.py @@ -1,7 +1,9 @@ import os import sys +import tempfile from pecan.tests import PecanTestCase +from six import b as b_ __here__ = os.path.dirname(__file__) @@ -131,14 +133,16 @@ class TestConf(PecanTestCase): def test_config_with_syntax_error(self): from pecan import configuration - path = ('bad', 'syntaxerror.py') - configuration.Config({}) - - self.assertRaises( - SyntaxError, - configuration.conf_from_file, - os.path.join(__here__, 'config_fixtures', *path) - ) + with tempfile.NamedTemporaryFile('wb') as f: + f.write(b_('\n'.join(['if false', 'var = 3']))) + f.flush() + configuration.Config({}) + + self.assertRaises( + SyntaxError, + configuration.conf_from_file, + f.name + ) def test_config_with_bad_import(self): from pecan import configuration |