PyQt我正在为应用程序创建一些单元测试pytest-qt。我想创建打开的图形窗口,进行一些测试然后关闭窗口,而不是为每个测试打开一个新窗口,即。对窗口本身使用模块固定装置。我成功地完成了这部分,通过调用本地函数 aQtBot而不是使用默认的固定装置,并删除模拟装置。所以我已经非常接近我的目标了。
但是,但我无法关闭窗口(并测试QMessageBox关闭事件)。
我红色示例,例如
如何处理模式对话框及其git讨论,或qmessage问题;这似乎与我的问题很接近。建议使用计时器等待出现,QMessageBox然后单击按钮选项,但显然我无法正确应用它们。在我的尝试中,pytest获得了平仓需求,但没有点击该dialog框。所以,我必须点击自己来完成测试。
这是一个带有 file 的小示例GUI.py:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QCoreApplication, Qt, QObject
from PyQt5.QtGui import QIcon
class Example(QMainWindow):
def __init__(self, parent = None):
super().__init__()
self.initUI(self)
def initUI(self, MainWindow):
# centralwidget
MainWindow.resize(346, 193)
self.centralwidget = QtWidgets.QWidget(MainWindow)
# The Action to quit …Run Code Online (Sandbox Code Playgroud) 我正在研究一个大型的fortran代码,在使用快速选项进行编译之前(为了对大型数据库进行测试),我通常使用"warnings"选项进行编译,以便检测并回溯所有问题.
因此gfortran -fbacktrace -ffpe-trap=invalid,zero,overflow,underflow -Wall -fcheck=all -ftrapv -g2编译时,我收到以下错误:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.
Backtrace for this error:
#0 0x7fec64cdfef7 in ???
#1 0x7fec64cdf12d in ???
#2 0x7fec6440e4af in ???
#3 0x7fec64a200b4 in ???
#4 0x7fec649dc5ce in ???
#5 0x4cf93a in __f_mod_MOD
at /f_mod.f90:132
#6 0x407d55 in main_loop_
at main.f90:419
#7 0x40cf5c in main_prog
at main.f90:180
#8 0x40d5d3 in main
at main.f90:68
Run Code Online (Sandbox Code Playgroud)
代码f_mod.f90:132的部分包含一个where循环:
! Compute s parameter
do i = 1, Imax
where (dprim …Run Code Online (Sandbox Code Playgroud) 我试图在地图中存储一些派生类。
我使用 share_ptr 存储它们以避免意外的释放。
不幸的是,在我的尝试中,它是有效的:程序编译并执行,但我收到一条错误消息。
我获得了以下MWE:
#include <iostream>
#include <map>
#include <memory>
#include <string>
#include <typeindex>
#include <typeinfo>
using namespace std;
class DataInOut {
public:
std::shared_ptr<void> data = nullptr;
std::type_index type = typeid(nullptr);
bool initialized = false;
bool optional = false;
// template <class Archive>
virtual bool dummy_funct(int &ar, const char* charName){
cout<< "serialize_or_throw from DataInOut address is an empty function." << endl;
return true;
}
DataInOut *clone() const { return new DataInOut(*this); }
~DataInOut(){}; // Destructor
};
template <typename …Run Code Online (Sandbox Code Playgroud)