From dccd9af4a16e172b62478d55d324fee9ba20283b Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Tue, 28 Jun 2022 21:28:36 +0200
Subject: [PATCH] Figuring out where to mock out gdb.Value

---
 gdb-port/tests/unit/ast.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gdb-port/tests/unit/ast.py b/gdb-port/tests/unit/ast.py
index 77f2647..90a4480 100644
--- a/gdb-port/tests/unit/ast.py
+++ b/gdb-port/tests/unit/ast.py
@@ -10,7 +10,7 @@ class HParseResultCreation(unittest.TestCase):
 		gdbv_patcher = unittest.mock.patch('gdb.Value', autospec=True)
 		hpt_patcher.start()
 		gdbv_patcher.start()
-		mocked_hparseresult = HParseResult(0xdeadbeef)
+		__class__.mocked_hparseresult = HParseResult(0xdeadbeef)
 		gdbv_patcher.stop()
 		hpt_patcher.stop()
 
@@ -21,6 +21,11 @@ class HParseResultCreation(unittest.TestCase):
 		with self.assertRaises(ValueError):
 			res = HParseResult(0)
 
-	#@patch("HParsedToken")
-	#def test_make_HParsedToken(self):
-	#	with patch.object(HParseResult, "read_member", return_value=0xdeadbeef):
+	#TODO: Mocking the read_member method might be needed
+	#TODO: MagicMock breaks self.token_type comparison
+	def test_make_HParsedToken(self):
+		gdbv_patcher = unittest.mock.patch('gdb.Value', autospec=True)
+		gdbv_patcher.start()
+		hpr = HParseResult(0xdeadbeef)
+		tok = hpr.make_HParsedToken()
+		gdbv_patcher.stop()
-- 
GitLab