From 94de56415c6dec97586c3ed80f1c569c76a1f172 Mon Sep 17 00:00:00 2001 From: sezanzeb <28510156+sezanzeb@users.noreply.github.com> Date: Sat, 4 Jan 2025 13:34:55 +0100 Subject: [PATCH] split test_set --- tests/unit/test_macros/test_set.py | 31 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/unit/test_macros/test_set.py b/tests/unit/test_macros/test_set.py index bea4f785..def8ab16 100644 --- a/tests/unit/test_macros/test_set.py +++ b/tests/unit/test_macros/test_set.py @@ -33,8 +33,6 @@ @test_setup class TestSet(MacroTestBase): - # `set` is also used in many other macro tests already, so there aren't many here. - async def test_set_key(self): code_b = keyboard_layout.get("b") macro = Parser.parse("set(foo, b).key($foo)", self.context, DummyMapping) @@ -47,14 +45,7 @@ async def test_set_key(self): ], ) - async def test_set(self): - await Parser.parse( - 'set(a, "foo")', - self.context, - DummyMapping, - ).run(self.handler) - self.assertEqual(macro_variables.get("a"), "foo") - + async def test_int_is_explicit_string(self): await Parser.parse( 'set( \t"b" \n, "1")', self.context, @@ -62,6 +53,7 @@ async def test_set(self): ).run(self.handler) self.assertEqual(macro_variables.get("b"), "1") + async def test_int_is_int(self): await Parser.parse( "set(a, 1)", self.context, @@ -69,6 +61,7 @@ async def test_set(self): ).run(self.handler) self.assertEqual(macro_variables.get("a"), 1) + async def test_none(self): await Parser.parse( "set(a, )", self.context, @@ -76,6 +69,24 @@ async def test_set(self): ).run(self.handler) self.assertEqual(macro_variables.get("a"), None) + async def test_set_case_sensitive_1(self): + await Parser.parse( + 'set(a, "foo")', + self.context, + DummyMapping, + ).run(self.handler) + self.assertEqual(macro_variables.get("a"), "foo") + self.assertEqual(macro_variables.get("A"), None) + + async def test_set_case_sensitive_2(self): + await Parser.parse( + 'set(A, "foo")', + self.context, + DummyMapping, + ).run(self.handler) + self.assertEqual(macro_variables.get("A"), "foo") + self.assertEqual(macro_variables.get("a"), None) + async def test_raises_error(self): self.assertRaises(MacroError, Parser.parse, "set($a, 1)", self.context) self.assertRaises(MacroError, Parser.parse, "set(1, 2)", self.context)