diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-06-14 23:40:41 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-06-14 23:40:41 +0300 |
commit | 9dae9fed0713625183ed1c780f93b0023fac92e1 (patch) | |
tree | 9175d95ee4b93fc503f1686c9c32f590e46ee61f | |
parent | 918e811db5ae568449aafe401c647f286f598664 (diff) | |
download | astroid-git-9dae9fed0713625183ed1c780f93b0023fac92e1.tar.gz |
Add test for coercion rules for floats and complex numbers.
-rw-r--r-- | astroid/tests/unittest_inference.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/astroid/tests/unittest_inference.py b/astroid/tests/unittest_inference.py index 4a2733d8..7e3c41dd 100644 --- a/astroid/tests/unittest_inference.py +++ b/astroid/tests/unittest_inference.py @@ -2074,6 +2074,22 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase): inferred = next(node.infer()) self.assertEqual(inferred.bool_value(), expected_value) + def test_infer_coercion_rules_for_floats_complex(self): + ast_nodes = test_utils.extract_node(''' + 1 + 1.0 #@ + 1 * 1.0 #@ + 2 - 1.0 #@ + 2 / 2.0 #@ + 1 + 1j #@ + 2 * 1j #@ + 2 - 1j #@ + 3 / 1j #@ + ''') + expected_values = [2.0, 1.0, 1.0, 1.0, 1 + 1j, 2j, 2 - 1j, -3j] + for node, expected in zip(ast_nodes, expected_values): + inferred = next(node.infer()) + self.assertEqual(inferred.value, expected) + class GetattrTest(unittest.TestCase): |