| 1 |
|
| 2 |
|
| 3 |
import Cheetah |
| 4 |
import Cheetah.Parser |
| 5 |
import Cheetah.Template |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class Chep_2_Conditionalized_Import_Behavior(): |
| 10 |
def test_ModuleLevelImport(self): |
| 11 |
''' Verify module level (traditional) import behavior ''' |
| 12 |
pass |
| 13 |
|
| 14 |
def test_InlineImport(self): |
| 15 |
''' Verify (new) inline import behavior works ''' |
| 16 |
template = ''' |
| 17 |
#def funky($s) |
| 18 |
#try |
| 19 |
#import urllib |
| 20 |
#except ImportError |
| 21 |
#pass |
| 22 |
#end try |
| 23 |
#return urllib.quote($s) |
| 24 |
#end def |
| 25 |
''' |
| 26 |
try: |
| 27 |
template = Cheetah.Template.Template.compile(template) |
| 28 |
except Cheetah.Parser.ParseError as ex: |
| 29 |
self.fail('Failed to properly generate code %s' % ex) |
| 30 |
template = template() |
| 31 |
rc = template.funky('abc def') |
| 32 |
assert rc == 'abc+def' |
| 33 |
|
| 34 |
def test_LegacyMode(self): |
| 35 |
''' Verify disabling of CHEP #2 works ''' |
| 36 |
pass |