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:
parent
664af7f399
commit
7a871eb8a4
|
@ -1,3 +1,2 @@
|
|||
[run]
|
||||
source=pecan
|
||||
omit=pecan/compat/dictconfig.py
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
if false
|
||||
var = 3
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue