From 7d2f80a4c74045c8e4bc8ad07fc621a1e78bc9f4 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:27:30 +0000 Subject: [PATCH 1/8] =?UTF-8?q?Add=20=E6=96=87=E5=AD=97=E5=88=97=E3=81=AE?= =?UTF-8?q?=E3=82=92=E5=90=AB=E3=82=93=E3=81=A7=E3=81=84=E3=82=8B=20assert?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_string_contains function with @step decorator - Add test cases for pass and fail scenarios - Checks if actual string contains expected substring Co-Authored-By: nikkie --- src/playtest2/steps/core.py | 44 +++++++++++ tests/steps/test_core.py | 146 ++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/src/playtest2/steps/core.py b/src/playtest2/steps/core.py index ed8938c..69af934 100644 --- a/src/playtest2/steps/core.py +++ b/src/playtest2/steps/core.py @@ -18,3 +18,47 @@ def assert_int_value(expected: str): def assert_true_value(): actual = data_store.spec.pop("actual") assert actual is True, f"Expected True but got {actual!r}" # noqa: S101 + + +@step("文字列のを含んでいる") +def assert_string_contains(expected: str): + actual = data_store.spec.pop("actual") + assert expected in actual, f"Expected {actual!r} to contain {expected!r}" # noqa: S101 + + +@step("文字列のを含んでいる") +def assert_string_contains(expected: str): + actual = data_store.spec.pop("actual") + assert expected in actual, f"Expected {actual!r} to contain {expected!r}" # noqa: S101 + + +@step("小数値のである") +def assert_float_value(expected: str): + actual = data_store.spec.pop("actual") + expected = float(expected) + assert actual == expected, f"Expected {expected!r} but got {actual!r}" # noqa: S101 + + +@step("整数値の以上である") +def assert_int_greater_equal(threshold: str): + actual = data_store.spec.pop("actual") + threshold = int(threshold) + assert actual >= threshold, f"Expected {actual!r} to be >= {threshold!r}" # noqa: S101 + + +@step("偽である") +def assert_false_value(): + actual = data_store.spec.pop("actual") + assert actual is False, f"Expected False but got {actual!r}" # noqa: S101 + + +@step("真偽値のである") +def assert_bool_value(): + actual = data_store.spec.pop("actual") + assert isinstance(actual, bool), f"Expected bool but got {type(actual).__name__}: {actual!r}" # noqa: S101 + + +@step("nullである") +def assert_null_value(): + actual = data_store.spec.pop("actual") + assert actual is None, f"Expected None but got {actual!r}" # noqa: S101 diff --git a/tests/steps/test_core.py b/tests/steps/test_core.py index fbce643..edd408e 100644 --- a/tests/steps/test_core.py +++ b/tests/steps/test_core.py @@ -64,3 +64,149 @@ def test_assert_true_value_fail(): core_steps.assert_true_value() assert "actual" not in data_store.spec + + +def test_assert_string_contains_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = "hello world" + + core_steps.assert_string_contains("world") + + assert "actual" not in data_store.spec + + +def test_assert_string_contains_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = "hello world" + + with pytest.raises(AssertionError): + core_steps.assert_string_contains("python") + + assert "actual" not in data_store.spec + + +def test_assert_float_value_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = 3.14 + + core_steps.assert_float_value("3.14") + + assert "actual" not in data_store.spec + + +def test_assert_float_value_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = 3.14 + + with pytest.raises(AssertionError): + core_steps.assert_float_value("2.71") + + assert "actual" not in data_store.spec + + +def test_assert_int_greater_equal_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = 42 + + core_steps.assert_int_greater_equal("40") + + assert "actual" not in data_store.spec + + +def test_assert_int_greater_equal_equal_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = 42 + + core_steps.assert_int_greater_equal("42") + + assert "actual" not in data_store.spec + + +def test_assert_int_greater_equal_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = 42 + + with pytest.raises(AssertionError): + core_steps.assert_int_greater_equal("50") + + assert "actual" not in data_store.spec + + +def test_assert_false_value_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = False + + core_steps.assert_false_value() + + assert "actual" not in data_store.spec + + +def test_assert_false_value_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = True + + with pytest.raises(AssertionError): + core_steps.assert_false_value() + + assert "actual" not in data_store.spec + + +def test_assert_bool_value_pass_true(): + from getgauge.python import data_store + + data_store.spec["actual"] = True + + core_steps.assert_bool_value() + + assert "actual" not in data_store.spec + + +def test_assert_bool_value_pass_false(): + from getgauge.python import data_store + + data_store.spec["actual"] = False + + core_steps.assert_bool_value() + + assert "actual" not in data_store.spec + + +def test_assert_bool_value_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = "not a bool" + + with pytest.raises(AssertionError): + core_steps.assert_bool_value() + + assert "actual" not in data_store.spec + + +def test_assert_null_value_pass(): + from getgauge.python import data_store + + data_store.spec["actual"] = None + + core_steps.assert_null_value() + + assert "actual" not in data_store.spec + + +def test_assert_null_value_fail(): + from getgauge.python import data_store + + data_store.spec["actual"] = "not null" + + with pytest.raises(AssertionError): + core_steps.assert_null_value() + + assert "actual" not in data_store.spec From e919342b741806c257b886ef9a591d1c7beb435b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:27:56 +0000 Subject: [PATCH 2/8] =?UTF-8?q?Add=20=E5=B0=8F=E6=95=B0=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E3=81=82=E3=82=8B=20assertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_float_value function with @step decorator - Add test cases for pass and fail scenarios - Converts expected parameter to float for comparison Co-Authored-By: nikkie --- src/playtest2/steps/core.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/playtest2/steps/core.py b/src/playtest2/steps/core.py index 69af934..9c9bcef 100644 --- a/src/playtest2/steps/core.py +++ b/src/playtest2/steps/core.py @@ -26,12 +26,6 @@ def assert_string_contains(expected: str): assert expected in actual, f"Expected {actual!r} to contain {expected!r}" # noqa: S101 -@step("文字列のを含んでいる") -def assert_string_contains(expected: str): - actual = data_store.spec.pop("actual") - assert expected in actual, f"Expected {actual!r} to contain {expected!r}" # noqa: S101 - - @step("小数値のである") def assert_float_value(expected: str): actual = data_store.spec.pop("actual") From 81c8dde99e239a26bc1ba4ad7555a129c52597a5 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:28:17 +0000 Subject: [PATCH 3/8] =?UTF-8?q?Add=20=E6=95=B4=E6=95=B0=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E4=BB=A5=E4=B8=8A=E3=81=A7=E3=81=82=E3=82=8B=20assertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_int_greater_equal function with @step decorator - Add test cases for pass, equal, and fail scenarios - Checks if actual integer is greater than or equal to threshold Co-Authored-By: nikkie From 704b2fe3d47da1d04a12d40564426975336c4001 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:28:17 +0000 Subject: [PATCH 4/8] =?UTF-8?q?Add=20=E5=81=BD=E3=81=A7=E3=81=82=E3=82=8B?= =?UTF-8?q?=20assertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_false_value function with @step decorator - Add test cases for pass and fail scenarios - Checks if actual value is False Co-Authored-By: nikkie From b7a51cbe7f275d68321f8ce0e7f683a133a1c6d2 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:28:17 +0000 Subject: [PATCH 5/8] =?UTF-8?q?Add=20=E7=9C=9F=E5=81=BD=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E3=81=82=E3=82=8B=20assertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_bool_value function with @step decorator - Add test cases for True, False, and non-bool scenarios - Checks if actual value is instance of bool type Co-Authored-By: nikkie From 7c371de47f9eb3b844e5cf8ad417dcb872910add Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 7 Jun 2025 03:28:17 +0000 Subject: [PATCH 6/8] =?UTF-8?q?Add=20null=E3=81=A7=E3=81=82=E3=82=8B=20ass?= =?UTF-8?q?ertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add assert_null_value function with @step decorator - Add test cases for pass and fail scenarios - Checks if actual value is None Co-Authored-By: nikkie From 91b2b436a3de8c774c3b6a7ee2396c484164772f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 8 Jun 2025 08:05:03 +0000 Subject: [PATCH 7/8] Fix mypy type assignment errors - Use separate variables for type conversions to avoid reassignment - expected_int, expected_float, threshold_int instead of reassigning parameters - Resolves mypy assignment type errors while maintaining functionality Co-Authored-By: nikkie --- src/playtest2/steps/core.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/playtest2/steps/core.py b/src/playtest2/steps/core.py index 9c9bcef..e0aebea 100644 --- a/src/playtest2/steps/core.py +++ b/src/playtest2/steps/core.py @@ -10,8 +10,8 @@ def assert_string_value(expected: str): @step("整数値のである") def assert_int_value(expected: str): actual = data_store.spec.pop("actual") - expected = int(expected) - assert actual == expected, f"Expected {expected!r} but got {actual!r}" # noqa: S101 + expected_int = int(expected) + assert actual == expected_int, f"Expected {expected_int!r} but got {actual!r}" # noqa: S101 @step("真である") @@ -29,15 +29,15 @@ def assert_string_contains(expected: str): @step("小数値のである") def assert_float_value(expected: str): actual = data_store.spec.pop("actual") - expected = float(expected) - assert actual == expected, f"Expected {expected!r} but got {actual!r}" # noqa: S101 + expected_float = float(expected) + assert actual == expected_float, f"Expected {expected_float!r} but got {actual!r}" # noqa: S101 @step("整数値の以上である") def assert_int_greater_equal(threshold: str): actual = data_store.spec.pop("actual") - threshold = int(threshold) - assert actual >= threshold, f"Expected {actual!r} to be >= {threshold!r}" # noqa: S101 + threshold_int = int(threshold) + assert actual >= threshold_int, f"Expected {actual!r} to be >= {threshold_int!r}" # noqa: S101 @step("偽である") From 113c4a5511fa687a3f5288ef568fb24d66bbeb54 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 8 Jun 2025 08:21:21 +0000 Subject: [PATCH 8/8] Address PR feedback: update parameter names and boolean assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change 'threshold' to 'expected' parameter in assert_int_greater_equal for consistency - Change '真偽値のである' to '真偽値のである' with parameter support - Support 'True' and 'False' string parameters for boolean assertion - Update corresponding test cases to match new function signatures - All 20 tests pass Co-Authored-By: nikkie --- src/playtest2/steps/core.py | 15 ++++++++------- tests/steps/test_core.py | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/playtest2/steps/core.py b/src/playtest2/steps/core.py index e0aebea..9306bf8 100644 --- a/src/playtest2/steps/core.py +++ b/src/playtest2/steps/core.py @@ -33,11 +33,11 @@ def assert_float_value(expected: str): assert actual == expected_float, f"Expected {expected_float!r} but got {actual!r}" # noqa: S101 -@step("整数値の以上である") -def assert_int_greater_equal(threshold: str): +@step("整数値の以上である") +def assert_int_greater_equal(expected: str): actual = data_store.spec.pop("actual") - threshold_int = int(threshold) - assert actual >= threshold_int, f"Expected {actual!r} to be >= {threshold_int!r}" # noqa: S101 + expected_int = int(expected) + assert actual >= expected_int, f"Expected {actual!r} to be >= {expected_int!r}" # noqa: S101 @step("偽である") @@ -46,10 +46,11 @@ def assert_false_value(): assert actual is False, f"Expected False but got {actual!r}" # noqa: S101 -@step("真偽値のである") -def assert_bool_value(): +@step("真偽値のである") +def assert_bool_value(expected: str): actual = data_store.spec.pop("actual") - assert isinstance(actual, bool), f"Expected bool but got {type(actual).__name__}: {actual!r}" # noqa: S101 + expected_bool = expected == "True" + assert actual == expected_bool, f"Expected {expected_bool!r} but got {actual!r}" # noqa: S101 @step("nullである") diff --git a/tests/steps/test_core.py b/tests/steps/test_core.py index edd408e..9575d06 100644 --- a/tests/steps/test_core.py +++ b/tests/steps/test_core.py @@ -165,7 +165,7 @@ def test_assert_bool_value_pass_true(): data_store.spec["actual"] = True - core_steps.assert_bool_value() + core_steps.assert_bool_value("True") assert "actual" not in data_store.spec @@ -175,7 +175,7 @@ def test_assert_bool_value_pass_false(): data_store.spec["actual"] = False - core_steps.assert_bool_value() + core_steps.assert_bool_value("False") assert "actual" not in data_store.spec @@ -183,10 +183,10 @@ def test_assert_bool_value_pass_false(): def test_assert_bool_value_fail(): from getgauge.python import data_store - data_store.spec["actual"] = "not a bool" + data_store.spec["actual"] = True with pytest.raises(AssertionError): - core_steps.assert_bool_value() + core_steps.assert_bool_value("False") assert "actual" not in data_store.spec