pytest-dsl 0.15.0__py3-none-any.whl → 0.15.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pytest_dsl/core/parser.py CHANGED
@@ -198,7 +198,30 @@ def p_expr_atom(p):
198
198
  elif isinstance(p[1], Node):
199
199
  p[0] = p[1]
200
200
  else:
201
- p[0] = Node('Expression', value=p[1])
201
+ # 为基本表达式设置行号信息和类型信息
202
+ expr_line = getattr(p.slice[1], 'lineno', None)
203
+
204
+ # 根据token类型创建不同的节点类型
205
+ token_type = p.slice[1].type
206
+ if token_type == 'STRING':
207
+ # 字符串字面量
208
+ expr_node = Node('StringLiteral', value=p[1])
209
+ elif token_type == 'NUMBER':
210
+ # 数字字面量
211
+ expr_node = Node('NumberLiteral', value=p[1])
212
+ elif token_type == 'ID':
213
+ # 变量引用
214
+ expr_node = Node('VariableRef', value=p[1])
215
+ elif token_type == 'PLACEHOLDER':
216
+ # 变量占位符 ${var}
217
+ expr_node = Node('PlaceholderRef', value=p[1])
218
+ else:
219
+ # 其他类型,保持原来的行为
220
+ expr_node = Node('Expression', value=p[1])
221
+
222
+ if expr_line is not None:
223
+ expr_node.set_position(expr_line)
224
+ p[0] = expr_node
202
225
 
203
226
 
204
227
  def p_boolean_expr(p):
@@ -265,8 +288,29 @@ def p_keyword_call(p):
265
288
  line_number = getattr(p.slice[1], 'lineno', None)
266
289
 
267
290
  if len(p) == 6:
268
- p[0] = Node('KeywordCall', [p[5]], p[2], line_number=line_number)
291
+ # 对于有参数的关键字调用,尝试获取更精确的行号
292
+ # 优先使用关键字名称的行号,其次是左括号的行号
293
+ keyword_line = getattr(p.slice[2], 'lineno', None)
294
+ if keyword_line is not None:
295
+ line_number = keyword_line
296
+
297
+ keyword_node = Node('KeywordCall', [p[5]], p[2],
298
+ line_number=line_number)
299
+
300
+ # 为参数列表中的每个参数也设置行号信息(如果可用)
301
+ if p[5] and isinstance(p[5], list):
302
+ for param in p[5]:
303
+ if (hasattr(param, 'set_position') and
304
+ not hasattr(param, 'line_number')):
305
+ # 如果参数没有行号,使用关键字的行号作为默认值
306
+ param.set_position(line_number)
307
+
308
+ p[0] = keyword_node
269
309
  else:
310
+ # 对于无参数的关键字调用,也优先使用关键字名称的行号
311
+ keyword_line = getattr(p.slice[2], 'lineno', None)
312
+ if keyword_line is not None:
313
+ line_number = keyword_line
270
314
  p[0] = Node('KeywordCall', [[]], p[2], line_number=line_number)
271
315
 
272
316
 
@@ -286,7 +330,15 @@ def p_parameter_items(p):
286
330
 
287
331
  def p_parameter_item(p):
288
332
  '''parameter_item : ID COLON expression'''
289
- p[0] = Node('ParameterItem', value=p[1], children=[p[3]])
333
+ # 获取参数名的行号
334
+ param_line = getattr(p.slice[1], 'lineno', None)
335
+ param_node = Node('ParameterItem', value=p[1], children=[p[3]])
336
+
337
+ # 设置参数节点的行号
338
+ if param_line is not None:
339
+ param_node.set_position(param_line)
340
+
341
+ p[0] = param_node
290
342
 
291
343
 
292
344
  def p_teardown(p):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-dsl
3
- Version: 0.15.0
3
+ Version: 0.15.2
4
4
  Summary: A DSL testing framework based on pytest
5
5
  Author: Chen Shuanglin
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
- pytest_dsl/__init__.py,sha256=VZz4wtSOB6NkY8jkO69YM8xVfD0y0v6xwob-ljkATnE,4817
2
- pytest_dsl/cli.py,sha256=pkom2w-7AWEDVH-khQGfUDs3NTeiG9pmWLk04gKD-gM,27289
1
+ pytest_dsl/__init__.py,sha256=QAn8612I9Fn7SnnuaU34ZiAImZ2sHnuVaLuHi3S_3p4,5254
2
+ pytest_dsl/cli.py,sha256=bH2z5-Onqpir1ymB-DB-tu-fuI1nWHcwVo_3ve9Hgco,12845
3
3
  pytest_dsl/conftest_adapter.py,sha256=cevEb0oEZKTZfUrGe1-CmkFByxKhUtjuurBJP7kpLc0,149
4
4
  pytest_dsl/main_adapter.py,sha256=pUIPN_EzY3JCDlYK7yF_OeLDVqni8vtG15G7gVzPJXg,181
5
5
  pytest_dsl/plugin.py,sha256=CEwi-ci2rMevaAl9PwBw2WKXWRbXuHI1IkkDV0I0VIo,2224
@@ -9,7 +9,7 @@ pytest_dsl/core/auto_decorator.py,sha256=9Mga-GB4AzV5nkB6zpfaq8IuHa0KOH8LlFvnWyH
9
9
  pytest_dsl/core/auto_directory.py,sha256=egyTnVxtGs4P75EIivRauLRPJfN9aZpoGVvp_Ma72AM,2714
10
10
  pytest_dsl/core/context.py,sha256=fXpVQon666Lz_PCexjkWMBBr-Xcd1SkDMp2vHar6eIs,664
11
11
  pytest_dsl/core/custom_keyword_manager.py,sha256=F9aSbth4x4-5nHb0N5uG04CpgwGnQv4RDGeRKR2WuIk,16001
12
- pytest_dsl/core/dsl_executor.py,sha256=DQVPLCh0_Z1PQtMdU_We5Pv1im_CDEwLI0q-9DkzmIQ,47992
12
+ pytest_dsl/core/dsl_executor.py,sha256=G3Ad97REt1jWwRvp7LS2Nq7zy3S2ZtYKlJeAJANDstI,60200
13
13
  pytest_dsl/core/dsl_executor_utils.py,sha256=ZJLSYSsiKHqg53d3Bl--ZF8m9abd5kpqdevWl31KEZg,2276
14
14
  pytest_dsl/core/execution_tracker.py,sha256=Pwcxraxt_xkOouq32KBqola-OVfnbaomCoMTyUIqoN4,9476
15
15
  pytest_dsl/core/global_context.py,sha256=NcEcS2V61MT70tgAsGsFWQq0P3mKjtHQr1rgT3yTcyY,3535
@@ -21,8 +21,9 @@ pytest_dsl/core/http_client.py,sha256=hdx8gI4JCmq1-96pbiKeyKzSQUzPAi08cRNmljiPQm
21
21
  pytest_dsl/core/http_request.py,sha256=6e-gTztH3wu2eSW27Nc0uPmyWjB6oBwndx8Vqnu5uyg,60030
22
22
  pytest_dsl/core/keyword_loader.py,sha256=3GQ4w5Zf2XdkoJ85uYXh9YB93_8L8OAb7vvuKE3-gVA,13864
23
23
  pytest_dsl/core/keyword_manager.py,sha256=5WZWwlYk74kGHh1T6WjCuVd8eelq2-UEXvDIe4U7rEI,7730
24
- pytest_dsl/core/lexer.py,sha256=WaLzt9IhtHiA90Fg2WGgfVztveCUhtgxzANBaEiy-F8,4347
25
- pytest_dsl/core/parser.py,sha256=iDxZ6MHa6EtDUieWDBYP36f2QYPBxKnIdoWgTrpulkI,14471
24
+ pytest_dsl/core/keyword_utils.py,sha256=1zIKzbA8Lhifc97skzN4oJV-2Cljzf9aVSutwjU7LaA,19847
25
+ pytest_dsl/core/lexer.py,sha256=o_EJIadfhgyCImI73Y9ybqlBE9AisgA6nOhxpXNlaMw,4648
26
+ pytest_dsl/core/parser.py,sha256=SvTQ4jgMSe3MITSu9PftraElPAzVaBbNPHMEk1H_lFY,16597
26
27
  pytest_dsl/core/parsetab.py,sha256=o4XbFKwpsi3fYmfI_F6u5NSM61Qp6gTx-Sfh1jDINxI,31767
27
28
  pytest_dsl/core/plugin_discovery.py,sha256=3pt3EXJ7EPF0rkUlyDZMVHkIiTy2vicdIIQJkrHXZjY,8305
28
29
  pytest_dsl/core/utils.py,sha256=q0AMdw5HO33JvlA3UJeQ7IXh1Z_8K1QlwiM1_yiITrU,5350
@@ -72,9 +73,9 @@ pytest_dsl/remote/keyword_client.py,sha256=BL80MOaLroUi0v-9sLtkJ55g1R0Iw9SE1k11I
72
73
  pytest_dsl/remote/keyword_server.py,sha256=vGIE3Bhh461xX_u1U-Cf5nrWL2GQFYdtQdcMWfFIYgE,22320
73
74
  pytest_dsl/remote/variable_bridge.py,sha256=dv-d3Gq9ttvvrXM1fdlLtoSOPB6vRp0_GBOwX4wvcy8,7121
74
75
  pytest_dsl/templates/keywords_report.html,sha256=7x84iq6hi08nf1iQ95jZ3izcAUPx6JFm0_8xS85CYws,31241
75
- pytest_dsl-0.15.0.dist-info/licenses/LICENSE,sha256=Rguy8cb9sYhK6cmrBdXvwh94rKVDh2tVZEWptsHIsVM,1071
76
- pytest_dsl-0.15.0.dist-info/METADATA,sha256=C0m-LwNfCj8xXE_CzU1rIUVCuUsxQkeodkC7IQxxDSk,29655
77
- pytest_dsl-0.15.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
- pytest_dsl-0.15.0.dist-info/entry_points.txt,sha256=PLOBbH02OGY1XR1JDKIZB1Em87loUvbgMRWaag-5FhY,204
79
- pytest_dsl-0.15.0.dist-info/top_level.txt,sha256=4CrSx4uNqxj7NvK6k1y2JZrSrJSzi-UvPZdqpUhumWM,11
80
- pytest_dsl-0.15.0.dist-info/RECORD,,
76
+ pytest_dsl-0.15.2.dist-info/licenses/LICENSE,sha256=Rguy8cb9sYhK6cmrBdXvwh94rKVDh2tVZEWptsHIsVM,1071
77
+ pytest_dsl-0.15.2.dist-info/METADATA,sha256=vfUUteu2RO84-TI0j0TngY18o_L1w1VTa2v94eX_XZc,29655
78
+ pytest_dsl-0.15.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
79
+ pytest_dsl-0.15.2.dist-info/entry_points.txt,sha256=PLOBbH02OGY1XR1JDKIZB1Em87loUvbgMRWaag-5FhY,204
80
+ pytest_dsl-0.15.2.dist-info/top_level.txt,sha256=4CrSx4uNqxj7NvK6k1y2JZrSrJSzi-UvPZdqpUhumWM,11
81
+ pytest_dsl-0.15.2.dist-info/RECORD,,