Skip to content
This repository
Newer
Older
100644 129 lines (115 sloc) 5.822 kb
e535482d »
2012-12-21 Packaged tests for running as a suite
1 if __name__ == "__main__":
2 import sys
3 sys.path.append('../plugin/python/')
e58ebc7d »
2012-12-21 Using unittest2 instead of unittest for Python 2.6 compat
4 import unittest2 as unittest
664227f1 »
2012-08-10 Fixed broken tests after refactoring
5 import vdebug.dbgp
fbadbaf9 »
2012-08-06 Debugging for python working
6 import xml.etree.ElementTree as ET
c003ac0a »
2012-08-03 Added test for context property
7
fbadbaf9 »
2012-08-06 Debugging for python working
8 class ContextPropertyDefaultTest(unittest.TestCase):
9 def __get_context_property(self,xml_string):
10 xml = ET.fromstring(xml_string)
11 firstnode = xml[0]
664227f1 »
2012-08-10 Fixed broken tests after refactoring
12 return vdebug.dbgp.ContextProperty(firstnode)
c003ac0a »
2012-08-03 Added test for context property
13
fbadbaf9 »
2012-08-06 Debugging for python working
14 def test_single_property(self):
15 prop = self.__get_context_property(\
16 """<?xml version="1.0" encoding="iso-8859-1"?>
17 <response xmlns="urn:debugger_protocol_v1"
18 xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
19 command="context_get" transaction_id="3"
20 context="0"><property name="$argc" fullname="$argc"
21 address="39795424"
22 type="int"><![CDATA[4]]></property></response>""")
c003ac0a »
2012-08-03 Added test for context property
23
fbadbaf9 »
2012-08-06 Debugging for python working
24 self.assertEqual(prop.display_name,'$argc')
25 self.assertEqual(prop.value,'4')
26 self.assertEqual(prop.type,'int')
27 self.assertEqual(prop.depth,0)
28 self.assertIsNone(prop.size)
29 self.assertFalse(prop.has_children)
c003ac0a »
2012-08-03 Added test for context property
30
fbadbaf9 »
2012-08-06 Debugging for python working
31 def test_undefined_property(self):
32 prop = self.__get_context_property(\
33 """<?xml version="1.0" encoding="iso-8859-1"?>
34 <response xmlns="urn:debugger_protocol_v1"
35 xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
36 command="context_get" transaction_id="3"
37 context="0"><property name="$uid"
38 fullname="$uid" type="uninitialized"></property></response>""")
c003ac0a »
2012-08-03 Added test for context property
39
fbadbaf9 »
2012-08-06 Debugging for python working
40 self.assertEqual(prop.display_name,'$uid')
41 self.assertEqual(prop.value,'')
42 self.assertEqual(prop.type,'uninitialized')
43 self.assertEqual(prop.depth,0)
44 self.assertIsNone(prop.size)
45 self.assertFalse(prop.has_children)
c003ac0a »
2012-08-03 Added test for context property
46
fbadbaf9 »
2012-08-06 Debugging for python working
47 def test_child_properties(self):
48 prop = self.__get_context_property(\
49 """<?xml version="1.0" encoding="iso-8859-1"?>
50 <response xmlns="urn:debugger_protocol_v1"
51 xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
52 command="context_get" transaction_id="3"
53 context="0"><property name="$argv"
54 fullname="$argv" address="39794056" type="array"
55 children="1" numchildren="4" page="0"
56 pagesize="32"><property name="0" fullname="$argv[0]"
57 address="39794368" type="string" size="19"
58 encoding="base64"><![CDATA[L3Vzci9sb2NhbC9iaW4vY2FrZQ==]]></property><property
59 name="1" fullname="$argv[1]" address="39794640"
60 type="string" size="8"
61 encoding="base64"><![CDATA[VGRkLnRlc3Q=]]></property><property
62 name="2" fullname="$argv[2]" address="39794904"
63 type="string" size="8"
64 encoding="base64"><![CDATA[LS1zdGRlcnI=]]></property><property
65 name="3" fullname="$argv[3]" address="39795168"
66 type="string" size="3"
67 encoding="base64"><![CDATA[QWxs]]></property></property></response>""")
c003ac0a »
2012-08-03 Added test for context property
68
fbadbaf9 »
2012-08-06 Debugging for python working
69 self.assertEqual(prop.display_name,'$argv')
70 self.assertEqual(prop.value,'')
71 self.assertEqual(prop.type,'array')
72 self.assertEqual(prop.depth,0)
73 self.assertTrue(prop.has_children)
74 self.assertEqual(prop.child_count(),4)
c003ac0a »
2012-08-03 Added test for context property
75
fbadbaf9 »
2012-08-06 Debugging for python working
76 class ContextPropertyAltTest(unittest.TestCase):
77 def __get_context_property(self,xml_string):
78 xml = ET.fromstring(xml_string)
79 firstnode = xml[0]
664227f1 »
2012-08-10 Fixed broken tests after refactoring
80 return vdebug.dbgp.ContextProperty(firstnode)
c003ac0a »
2012-08-03 Added test for context property
81
fbadbaf9 »
2012-08-06 Debugging for python working
82 def test_single_property(self):
83 prop = self.__get_context_property(\
84 """<?xml version="1.0" encoding="iso-8859-1"?>
85 <response xmlns="urn:debugger_protocol_v1"
86 xmlns:xdebug="http://xdebug.org/dbgp/xdebug"
87 command="context_get" transaction_id="3"
88 context="0"><property type="int" children="0" size="0"><value><![CDATA[1]]></value><name encoding="base64"><![CDATA[bXl2YXI=
89 ]]></name><fullname encoding="base64"><![CDATA[bXl2YXI=
90 ]]></fullname></property></response>""")
91
92 self.assertEqual(prop.display_name,'myvar')
93 self.assertEqual(prop.value,'1')
94 self.assertEqual(prop.type,'int')
95 self.assertEqual(prop.depth,0)
96 self.assertFalse(prop.has_children)
97
98 def test_child_properties(self):
99 prop = self.__get_context_property(\
100 """<?xml version="1.0" encoding="utf-8"?>
101 <response xmlns="urn:debugger_protocol_v1" command="contex_get" context="0" transaction_id="13"><property pagesize="10" numchildren="3" children="1" type="list" page="0" size="3"><property type="int" children="0" size="0"><value><![CDATA[1]]></value><name encoding="base64"><![CDATA[WzBd
102 ]]></name><fullname encoding="base64"><![CDATA[bXlsaXN0WzBd
103 ]]></fullname></property><property type="int" children="0" size="0"><value><![CDATA[2]]></value><name encoding="base64"><![CDATA[WzFd
104 ]]></name><fullname encoding="base64"><![CDATA[bXlsaXN0WzFd
105 ]]></fullname></property><property type="int" children="0" size="0"><value><![CDATA[3]]></value><name encoding="base64"><![CDATA[WzJd
106 ]]></name><fullname encoding="base64"><![CDATA[bXlsaXN0WzJd
107 ]]></fullname></property><name encoding="base64"><![CDATA[bXlsaXN0
108 ]]></name><fullname encoding="base64"><![CDATA[bXlsaXN0
109 ]]></fullname></property></response>""")
110
111 self.assertEqual(prop.display_name,'mylist')
112 self.assertEqual(prop.value,'')
113 self.assertEqual(prop.type,'list')
114 self.assertEqual(prop.depth,0)
115 self.assertTrue(prop.has_children)
116 self.assertEqual(prop.child_count(),3)
117
118 def test_string(self):
119 prop = self.__get_context_property(\
120 """<?xml version="1.0" encoding="utf-8"?>
121 <response xmlns="urn:debugger_protocol_v1" command="contex_get" context="0" transaction_id="13"><property type="str" children="0" size="5"><value encoding="base64"><![CDATA[d29ybGQ=
122 ]]></value><name encoding="base64"><![CDATA[b2JqX3Zhcg==
123 ]]></name><fullname encoding="base64"><![CDATA[b2JqLm9ial92YXI=
124 ]]></fullname></property></response>""")
125
126 self.assertEqual(prop.display_name,'obj.obj_var')
127 self.assertEqual(prop.value,'`world`')
128 self.assertEqual(prop.type,'str')
129 self.assertFalse(prop.has_children)
c003ac0a »
2012-08-03 Added test for context property
130
Something went wrong with that request. Please try again.