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
This commit is contained in:
Ryan Petrello 2013-10-23 10:23:49 -04:00
parent 664af7f399
commit 7a871eb8a4
3 changed files with 11 additions and 10 deletions

View File

@ -1,3 +1,2 @@
[run]
source=pecan
omit=pecan/compat/dictconfig.py

View File

@ -1,2 +0,0 @@
if false
var = 3

View File

@ -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({})
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,
os.path.join(__here__, 'config_fixtures', *path)
)
self.assertRaises(
SyntaxError,
configuration.conf_from_file,
f.name
)
def test_config_with_bad_import(self):
from pecan import configuration