Commit f377f3eb authored by Nsukami Patrick's avatar Nsukami Patrick
Browse files

black: format without any compromise

parent d8d053066c54
Pipeline #110368 failed with stages
in 2 minutes and 14 seconds
......@@ -33,10 +33,12 @@ CURRENT_DIR = Path(__file__).parent
if os.environ.get("RQL_FORCE_GECODE"):
MyBuildExt = build_ext.build_ext
else:
class MyBuildExt(build_ext.build_ext):
"""Extend build_ext command to pass through compilation error.
In fact, if gecode extension fail, rql will use logilab.constraint
"""
def run(self):
try:
build_ext.build_ext.run(self)
......@@ -55,9 +57,10 @@ else:
"================================\n"
)
def gecode_version():
version = [6, 2, 0]
if ( CURRENT_DIR / "data/gecode_version.cc" ).exists() :
if (CURRENT_DIR / "data/gecode_version.cc").exists():
try:
subprocess.check_call(
["g++", "-o", "gecode_version", "data/gecode_version.cc"]
......@@ -69,9 +72,11 @@ def gecode_version():
pass
return version
def encode_version(a, b, c):
return (a << 16) + (b << 8) + c
GECODE_VERSION = encode_version(*gecode_version())
if sys.platform != "win32":
......@@ -85,7 +90,8 @@ if sys.platform != "win32":
"gecodesearch",
],
extra_compile_args=["-DGE_VERSION=%s" % GECODE_VERSION],
)]
)
]
else:
extensions = [
Extension(
......@@ -98,12 +104,13 @@ else:
"GecodeSupport-3-3-1-r-x86",
],
extra_compile_args=["/DGE_VERSION=%s" % GECODE_VERSION, "/EHsc"],
)]
)
]
setup_args = dict(
ext_modules = extensions,
cmdclass = {"build_ext": MyBuildExt},
ext_modules=extensions,
cmdclass={"build_ext": MyBuildExt},
)
setup(**setup_args)
......@@ -56,7 +56,7 @@ class EtypeFromPyobjTC(TestCase):
def test_string(self):
self.assertEqual(nodes.etype_from_pyobj("hop"), "String")
self.assertEqual(nodes.etype_from_pyobj(u"hop"), "String")
self.assertEqual(nodes.etype_from_pyobj("hop"), "String")
class TypesRestrictionNodesTest(TestCase):
......@@ -683,35 +683,35 @@ class NodesTest(TestCase):
tree = parse("Person X")
self.assertEqual(tree.as_string(), "Any X WHERE X is Person")
tree = parse(u"Any X WHERE X has_text 'hh'")
self.assertEqual(tree.as_string(), u'Any X WHERE X has_text "hh"')
tree = parse(u"Any X WHERE X has_text %(text)s")
tree = parse("Any X WHERE X has_text 'hh'")
self.assertEqual(tree.as_string(), 'Any X WHERE X has_text "hh"')
tree = parse("Any X WHERE X has_text %(text)s")
self.assertEqual(
tree.as_string({"text": u"hh"}), u'Any X WHERE X has_text "hh"'
tree.as_string({"text": "hh"}), 'Any X WHERE X has_text "hh"'
)
tree = parse(u"Any X WHERE X has_text %(text)s")
tree = parse("Any X WHERE X has_text %(text)s")
self.assertEqual(
tree.as_string({"text": u'h"h'}), u'Any X WHERE X has_text "h\\"h"'
tree.as_string({"text": 'h"h'}), 'Any X WHERE X has_text "h\\"h"'
)
tree = parse(u"Any X WHERE X has_text %(text)s")
tree = parse("Any X WHERE X has_text %(text)s")
self.assertEqual(
tree.as_string({"text": u"h\"'h"}), u'Any X WHERE X has_text "h\\"\'h"'
tree.as_string({"text": "h\"'h"}), 'Any X WHERE X has_text "h\\"\'h"'
)
def test_as_string_no_encoding(self):
tree = parse(u"Any X WHERE X has_text 'hh'")
self.assertEqual(tree.as_string(), u'Any X WHERE X has_text "hh"')
tree = parse(u"Any X WHERE X has_text %(text)s")
tree = parse("Any X WHERE X has_text 'hh'")
self.assertEqual(tree.as_string(), 'Any X WHERE X has_text "hh"')
tree = parse("Any X WHERE X has_text %(text)s")
self.assertEqual(
tree.as_string(kwargs={"text": u"hh"}), u'Any X WHERE X has_text "hh"'
tree.as_string(kwargs={"text": "hh"}), 'Any X WHERE X has_text "hh"'
)
def test_as_string_now_today_null(self):
tree = parse(u"Any X WHERE X name NULL")
tree = parse("Any X WHERE X name NULL")
self.assertEqual(tree.as_string(), "Any X WHERE X name NULL")
tree = parse(u"Any X WHERE X creation_date NOW")
tree = parse("Any X WHERE X creation_date NOW")
self.assertEqual(tree.as_string(), "Any X WHERE X creation_date NOW")
tree = parse(u"Any X WHERE X creation_date TODAY")
tree = parse("Any X WHERE X creation_date TODAY")
self.assertEqual(tree.as_string(), "Any X WHERE X creation_date TODAY")
def test_get_type_is_in(self):
......@@ -797,7 +797,7 @@ class NodesTest(TestCase):
)
def test_repr_encoding(self):
tree = parse(u'Any N where NOT N has_text "bidle"')
tree = parse('Any N where NOT N has_text "bidle"')
repr(tree)
def test_get_description_mainvar_objrel(self):
......@@ -821,31 +821,31 @@ class NodesTest(TestCase):
self.assertEqual(tree.get_description(0), [["String"]])
def test_replace_node_select(self):
tree = sparse(u'Any X, MAX(X) WHERE X name "toto tata"')
tree = sparse('Any X, MAX(X) WHERE X name "toto tata"')
select = tree.children[0]
funcnode = sparse(u"Any MAX(X)").children[0].selection[0]
funcnode = sparse("Any MAX(X)").children[0].selection[0]
select.replace(funcnode, nodes.Constant(1.0, "Float"))
def test_replace_node_orderby(self):
tree = sparse(u'Any X ORDERBY MAX(X) WHERE X name "toto tata"')
tree = sparse('Any X ORDERBY MAX(X) WHERE X name "toto tata"')
select = tree.children[0]
funcnode = sparse(u"Any X ORDERBY MAX(X)").children[0].orderby[0]
funcnode = sparse("Any X ORDERBY MAX(X)").children[0].orderby[0]
select.replace(funcnode, nodes.Constant(1.0, "Float"))
def test_replace_node_groupby(self):
tree = sparse(u'Any X GROUPBY X, MAX(X) WHERE X name "toto tata"')
tree = sparse('Any X GROUPBY X, MAX(X) WHERE X name "toto tata"')
select = tree.children[0]
funcnode = sparse(u"Any MAX(X)").children[0].selection[0]
funcnode = sparse("Any MAX(X)").children[0].selection[0]
select.replace(funcnode, nodes.Constant(1.0, "Float"))
def test_replace_node_having(self):
tree = sparse(u'Any X WHERE X name "toto tata" HAVING MAX(X) > 1')
tree = sparse('Any X WHERE X name "toto tata" HAVING MAX(X) > 1')
select = tree.children[0]
funcnode = sparse(u"Any X HAVING MAX(X) > 1").children[0].having[0]
funcnode = sparse("Any X HAVING MAX(X) > 1").children[0].having[0]
select.replace(funcnode, nodes.Constant(1.0, "Float"))
def test_undo_node_having(self):
qs = u"Any X WHERE X name N"
qs = "Any X WHERE X name N"
tree = sparse(qs)
select = tree.children[0]
select.save_state()
......
......@@ -70,7 +70,7 @@ SPEC_QUERIES = (
"X owned_by U, U login 'syt', X available true;"
),
(
u"Document X WHERE X occurence_of F, F class C, C name 'Bande dessinée', "
"Document X WHERE X occurence_of F, F class C, C name 'Bande dessinée', "
"X owned_by U, U login 'syt', X available true;"
),
(
......@@ -175,7 +175,7 @@ class ParserHercule(unittest.TestCase):
raise
def test_unicode_constant(self):
tree = self.parse(u"Any X WHERE X name 'Ångström';")
tree = self.parse("Any X WHERE X name 'Ångström';")
base = tree.children[0].where
comparison = base.children[1]
self.assertIsInstance(comparison, nodes.Comparison)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment