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:
@@ -1,3 +1,2 @@
|
|||||||
[run]
|
[run]
|
||||||
source=pecan
|
source=pecan
|
||||||
omit=pecan/compat/dictconfig.py
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
if false
|
|
||||||
var = 3
|
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from pecan.tests import PecanTestCase
|
from pecan.tests import PecanTestCase
|
||||||
|
from six import b as b_
|
||||||
|
|
||||||
|
|
||||||
__here__ = os.path.dirname(__file__)
|
__here__ = os.path.dirname(__file__)
|
||||||
@@ -131,14 +133,16 @@ class TestConf(PecanTestCase):
|
|||||||
|
|
||||||
def test_config_with_syntax_error(self):
|
def test_config_with_syntax_error(self):
|
||||||
from pecan import configuration
|
from pecan import configuration
|
||||||
path = ('bad', 'syntaxerror.py')
|
with tempfile.NamedTemporaryFile('wb') as f:
|
||||||
configuration.Config({})
|
f.write(b_('\n'.join(['if false', 'var = 3'])))
|
||||||
|
f.flush()
|
||||||
|
configuration.Config({})
|
||||||
|
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
SyntaxError,
|
SyntaxError,
|
||||||
configuration.conf_from_file,
|
configuration.conf_from_file,
|
||||||
os.path.join(__here__, 'config_fixtures', *path)
|
f.name
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_config_with_bad_import(self):
|
def test_config_with_bad_import(self):
|
||||||
from pecan import configuration
|
from pecan import configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user