python - 谁能告诉我在开始测试时遇到的以下错误
问题描述
这是我得到的错误: SyntaxError: !!WHILE IMPORTING!! 不匹配的输入 'def' 期望 INDENT(cancel_receipt.py,第 17 行)
完整的错误堆栈如下:
[error] script [ full_RT_test_run ] stopped with error at line --unknown--
[error] Error caused by: Traceback (most recent call last): File "C:\Users\Administrator\Desktop\Sikuli\on till regression test\full_RT_test_run.sikuli\full_RT_test_run.py", line 3, in <module> import cancel_receipt File "C:\Users\Administrator\AppData\Roaming\Sikulix\Lib\sikuli\SikuliImporter.py", line 45, in load_module return self._load_module(module_name) File "C:\Users\Administrator\AppData\Roaming\Sikulix\Lib\sikuli\SikuliImporter.py", line 34, in _load_module return imp.load_module(fullname, file, pathname, desc) File "<string>", line None SyntaxError: !!WHILE IMPORTING!! mismatched input 'def' expecting INDENT (cancel_receipt.py, line 17)
这是我的 cancel_receipt 类:
import general_buttons
import general_functions
import globals
import gui_screens
import error_handling
from sikuli import *
global process_name
process_name = 'Cancel Receipt'
global four_eyes_test
four_eyes_test = 0
def cancel_receipt():
def cancel_receipt():
globals.current_process_name = process_name
general_functions.errorhandling("ABORT")
general_functions.extended_wait(['main_page_key_pad'], globals.very_long_wait, 0)
general_functions.start_of_test_case('CANCEL RECEIPT TEST CASES')
x = 0
# THIS NEEDS TO BE READ FROM THE CUSTOMIZATION FILE
while x < 3:
# wait for the main screen to be there
general_functions.extended_wait(['main_page_key_pad'], globals.very_long_wait, 0)
# if it's the regression test get the number of articles specified in te test settings
general_functions.fill_basket(globals.general_articles[0][4], 1)
if x == 0: # cancel before the total button is clicked
general_functions.start_of_test_case('TC cancel receipt before total button is clicked')
receipt_meta_data_array = general_functions.get_receipt_meta_data()
general_buttons.main_page_key_pad_btns_click('CANCEL')
else: # cancel after the total button is clicked
# click TOTAL button
general_buttons.main_page_key_pad_btns_click('TOTAL')
general_functions.start_of_test_case('TC cancel receipt after total button is clicked')
receipt_meta_data_array = general_functions.get_receipt_meta_data()
# this is actually the CANCEL TRANSACTION button but it's in the same location as the CANCEL button
general_buttons.main_page_key_pad_btns_click('CANCEL')
general_functions.four_eyes_enhanced(globals.users[2], globals.users
这是我 full_RT_test_run.py 的开始
import init
import basic_sale
import cancel_receipt
import commission_sale
import drop_off
解决方案
你有一个重复的行:
def cancel_receipt():
def cancel_receipt():
另请注意,这不是一个真正的类,它是一个模块。
推荐阅读
- git - 如何删除 git 中的永久登录名和密码输入?
- javascript - 无法读取 axios 包装器未定义的属性“then”
- python-3.x - 在 PyQt5 中,如何使用 Drag&Drop 正确移动 QTableView 中的行
- c# - 使用 Process.Start 打开资源管理器窗口会创建过多的 explorer.exe 进程
- python - 根据打印输出发送电子邮件 - Python
- vue.js - 我提到了 vue.js 公式,但我得到一个错误
- java - 迭代自定义对象列表,过滤条件并设置特定属性
- sap-cloud-sdk - 如何使用 Cloud SDK v3 在 Bapi 调用中提供结构参数作为导入
- python - 在 Python 中从数据框中打开下载的文件时出错
- python - 添加进度条以使用熊猫读取数据框?