Write a test for builds() check
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
4d625fff20
commit
66e5af4a82
@ -97,7 +97,7 @@ def builds(_type):
|
||||
|
||||
unpythonic_chars = ["-"]
|
||||
really_ok = ["-"]
|
||||
if True in (x in str_type(_type) for x in unpythonic_chars):
|
||||
if any(x in unpythonic_chars for x in str_type(_type)):
|
||||
if _type not in really_ok:
|
||||
raise TypeError("`build' needs to be *post* translated strings, "
|
||||
"Mr. / Mrs. Hypser. -- `%s' sucks." % (_type))
|
||||
|
@ -27,11 +27,21 @@ if sys.version_info[0] <= 2 and sys.version_info[1] <= 6:
|
||||
else:
|
||||
import unittest
|
||||
|
||||
|
||||
from hy import compiler
|
||||
from hy.models.expression import HyExpression
|
||||
from hy.models.list import HyList
|
||||
from hy.models.symbol import HySymbol
|
||||
from hy.compiler import HyASTCompiler
|
||||
|
||||
|
||||
class CompilerTest(unittest.TestCase):
|
||||
|
||||
def test_builds_with_dash(self):
|
||||
self.assert_(callable(compiler.builds("foobar")))
|
||||
self.assert_(callable(compiler.builds("foo_bar")))
|
||||
self.assert_(callable(compiler.builds("-")))
|
||||
self.assertRaisesRegexp(TypeError,
|
||||
"\*post\* translated strings",
|
||||
compiler.builds, "foobar-with-dash-")
|
||||
|
||||
|
||||
class HyASTCompilerTest(unittest.TestCase):
|
||||
@ -46,7 +56,7 @@ class HyASTCompilerTest(unittest.TestCase):
|
||||
return h
|
||||
|
||||
def setUp(self):
|
||||
self.c = HyASTCompiler()
|
||||
self.c = compiler.HyASTCompiler()
|
||||
|
||||
def test_fn_compiler_empty_function(self):
|
||||
ret = self.c.compile_function_def(
|
||||
|
Loading…
Reference in New Issue
Block a user