import test_utils
import repyhelper

TESTFILE = "rhtest_callargs.r2py"
#Make sure we have fresh translations per test run

test_utils.cleanup_translations([TESTFILE])


#Now test that the string escaping works properly
modname = repyhelper.translate(TESTFILE, callargs=["\"a\"", "samoas", "\\\'b\"\\", ""])
mod = __import__(modname)


if mod.callargs[0] != "\"a\"":
  print "double quotes not properly escaped:", mod.callargs[0]
if mod.callargs[1] != "samoas":
  print "simple string badly escaped:", mod.callargs[2]
if mod.callargs[2] != "\\\'b\"\\":
  print "double/single quotes not escaped properly:", mod.callargs[1]
if mod.callargs[3] != "":
  print "empty string improperly passed:", mod.callargs[1]

test_utils.cleanup_translations([TESTFILE])
import time
time.sleep(1)
Beispiel #2
0
  
  Uses files of the form rhtestrecursion_n.repy
  
  No output indicates success
  
"""

TESTFILES = [
    'rhtestrecursion_1.repy', 'rhtestrecursion_2.repy',
    'rhtestrecursion_3.repy', 'rhtestrecursion_4.repy'
]

import repyhelper
import test_utils

test_utils.cleanup_translations(TESTFILES)

#This tests circular includes
translation = repyhelper.translate(TESTFILES[0])
if translation == "":
    print "Error translating circular recursion"
else:
    #actually include it to make sure the translation was valid
    mod = __import__(translation)

test_utils.cleanup_translations(TESTFILES)

#Tests self include
translation = repyhelper.translate(TESTFILES[-1])
if translation == "":
    print "Error translating self-include"
"""
Test the callargs parameter of the translation calls, to make sure it actually
gets used

"""

import repyhelper
import test_utils

TESTFILE = "rhtest_callargs.repy"

#Make sure we have fresh translations per test run
test_utils.cleanup_translations([TESTFILE])

modname = repyhelper.translate(TESTFILE, callargs=["", "samoas"])
mod = __import__(modname)

if mod.num_callargs() is not 2:
    print "translate had wrong number of callargs:", mod.num_callargs()
    print "callargs =", mod.callargs

test_utils.cleanup_translations([TESTFILE])
import time
time.sleep(1)
Beispiel #4
0
Description:
  Perform various tests on recursive/circular includes/imports/translates
  
  Uses files of the form rhtestrecursion_n.repy
  
  No output indicates success
  
"""

TESTFILES = ['rhtestrecursion_1.repy', 'rhtestrecursion_2.repy', 'rhtestrecursion_3.repy', 'rhtestrecursion_4.repy']


import repyhelper
import test_utils

test_utils.cleanup_translations(TESTFILES)

#This tests circular includes
translation = repyhelper.translate(TESTFILES[0])
if translation == "":
  print "Error translating circular recursion"
else:
  #actually include it to make sure the translation was valid
  mod = __import__(translation)
 
test_utils.cleanup_translations(TESTFILES)
  
  
#Tests self include  
translation = repyhelper.translate(TESTFILES[-1])
if translation == "":