我正在尝试使用class menudemo(QMainWindow):
def __init__(self, parent = None):
super(menudemo, self).__init__(parent)
layout = QHBoxLayout()
bar = self.menuBar()
file = bar.addMenu("ملف")
file.addAction("الجديد")
save = QAction("حفظ",self)
file.addAction(save)
edit = file.addMenu("تصحيح")
edit.addAction("نسخ")
edit.addAction("معجون")
quit = QAction("استقال",self)
file.addAction(quit)
file.triggered[QAction].connect(self.processtrigger)
self.setLayout(layout)
self.setWindowTitle("RTL")
def processtrigger(self,q):
print(q.text()+" is triggered")
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setLayoutDirection(Qt.RightToLeft)
ex = menudemo()
ex.show()
sys.exit(app.exec_())
和rspec
进行Rails应用程序中的验收测试。
我有FactoryGirl
,Program
,ProgramLesson
,Course
个对象。
以下是模型:
Lesson
以下是这些东西的工厂:
class Program < ApplicationRecord
has_many :program_lessons
has_many :courses
end
class ProgramLesson < ApplicationRecord
has_many :lessons
end
class Course < ApplicationRecord
belongs_to :program
has_many :lessons
end
class Lesson < ApplicationRecord
belongs_to :program_lesson
belongs_to :course
end
因此,工厂正在为 FactoryGirl.define do
factory :program do
after(:create) do |object|
create_list(:program_lesson, 10, program: object)
create(:course, program: object)
end
end
FactoryGirl.define do
factory :course do
program
after(:create) { |object| object.program.program_lessons.each { |pl| create(:lesson, course: object, program_lesson:
end
end
创建program
,然后program_lessons
,然后为program
创建course
,然后program
属于course.lessons
和course
。
问题是program_lesson
只会在创建course.lessons
和byebug
之前创建。为什么会这样?