diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-10-23 10:23:49 -0400 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-10-23 10:31:25 -0400 |
commit | 7a871eb8a4985e4795ada15d89867b81e2685908 (patch) | |
tree | 51d4acca26e5f21f54a423f1b1ae06bbd8b705b3 /pecan/tests | |
parent | 664af7f3998549ff1bee7b16672cf2a226627662 (diff) | |
download | pecan-7a871eb8a4985e4795ada15d89867b81e2685908.tar.gz |
Replace an "invalid syntax" Python test fixture with a generated tempfile.
This will resolve warnings when installing with easy_install, and also allows
us to not include a invalid-syntax file in our distribution (even though it's
only used for tests).
Fixes-bug: 1243667
Change-Id: I2bfe0d2a5b2f3944cd97951b9285d153bbcb9362
Diffstat (limited to 'pecan/tests')
-rw-r--r-- | pecan/tests/config_fixtures/bad/syntaxerror.py | 2 | ||||
-rw-r--r-- | pecan/tests/test_conf.py | 20 |
2 files changed, 12 insertions, 10 deletions
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 |