From ad23425b70226b1facef426f3d1843dc886ef09f Mon Sep 17 00:00:00 2001 From: Alexander Loechel Date: Tue, 2 Oct 2018 11:21:55 +0200 Subject: [PATCH 1/2] seperate List, Set and Dict check --- tests/transformer/test_comparators.py | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/transformer/test_comparators.py b/tests/transformer/test_comparators.py index bb056f7..bb34e5d 100644 --- a/tests/transformer/test_comparators.py +++ b/tests/transformer/test_comparators.py @@ -52,12 +52,36 @@ def test_RestrictingNodeTransformer__visit_IsNot__1(e_eval): @pytest.mark.parametrize(*e_eval) -def test_RestrictingNodeTransformer__visit_In__1(e_eval): +def test_RestrictingNodeTransformer__visit_In_List(e_eval): """It allows `in` expressions.""" assert e_eval('2 in [1, 2, 3]') is True @pytest.mark.parametrize(*e_eval) -def test_RestrictingNodeTransformer__visit_NotIn__1(e_eval): +def test_RestrictingNodeTransformer__visit_NotIn_List(e_eval): """It allows `in` expressions.""" assert e_eval('2 not in [1, 2, 3]') is False + + +@pytest.mark.parametrize(*e_eval) +def test_RestrictingNodeTransformer__visit_In_Set(e_eval): + """It allows `in` expressions.""" + assert e_eval('2 in {1, 1, 2, 3}') is True + + +@pytest.mark.parametrize(*e_eval) +def test_RestrictingNodeTransformer__visit_NotIn_Set(e_eval): + """It allows `in` expressions.""" + assert e_eval('2 not in {1, 2, 3}') is False + + +@pytest.mark.parametrize(*e_eval) +def test_RestrictingNodeTransformer__visit_In_Dict(e_eval): + """It allows `in` expressions.""" + assert e_eval('2 in {1: 1, 2: 2, 3: 3}') is True + + +@pytest.mark.parametrize(*e_eval) +def test_RestrictingNodeTransformer__visit_NotIn_Dict(e_eval): + """It allows `in` expressions.""" + assert e_eval('2 not in {1: 1, 2: 2, 3: 3}') is False From 1f938da8b80e36902d8c912a4e1a7e02bd370d01 Mon Sep 17 00:00:00 2001 From: Alexander Loechel Date: Tue, 2 Oct 2018 13:26:04 +0200 Subject: [PATCH 2/2] correct docstrings --- tests/transformer/test_comparators.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/transformer/test_comparators.py b/tests/transformer/test_comparators.py index bb34e5d..df26722 100644 --- a/tests/transformer/test_comparators.py +++ b/tests/transformer/test_comparators.py @@ -53,35 +53,35 @@ def test_RestrictingNodeTransformer__visit_IsNot__1(e_eval): @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_In_List(e_eval): - """It allows `in` expressions.""" + """It allows `in` expressions for lists.""" assert e_eval('2 in [1, 2, 3]') is True @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_NotIn_List(e_eval): - """It allows `in` expressions.""" + """It allows `not in` expressions for lists.""" assert e_eval('2 not in [1, 2, 3]') is False @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_In_Set(e_eval): - """It allows `in` expressions.""" + """It allows `in` expressions for sets.""" assert e_eval('2 in {1, 1, 2, 3}') is True @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_NotIn_Set(e_eval): - """It allows `in` expressions.""" + """It allows `not in` expressions for sets.""" assert e_eval('2 not in {1, 2, 3}') is False @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_In_Dict(e_eval): - """It allows `in` expressions.""" + """It allows `in` expressions for dicts.""" assert e_eval('2 in {1: 1, 2: 2, 3: 3}') is True @pytest.mark.parametrize(*e_eval) def test_RestrictingNodeTransformer__visit_NotIn_Dict(e_eval): - """It allows `in` expressions.""" + """It allows `not in` expressions for dicts.""" assert e_eval('2 not in {1: 1, 2: 2, 3: 3}') is False