diff --git a/hy/compiler.py b/hy/compiler.py index ea3c5de..7122a97 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -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)) diff --git a/tests/compilers/test_compiler.py b/tests/compilers/test_compiler.py index 5f93144..246534d 100644 --- a/tests/compilers/test_compiler.py +++ b/tests/compilers/test_compiler.py @@ -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(