Tag: 装置

工厂女孩+ Mongoidembedded文件夹具

假设您有以下mongoid文档: class User include Mongoid::Document embeds_one :name end class UserName include Mongoid::Document field :first field :last_initial embedded_in :user end 如何创build一个初始化embedded式名字和最后一个字母的工厂女孩​​工厂? 另外你怎么做embeds_many关系?

py.test:将一个parameter passing给一个fixture函数

我正在使用py.test来testing包装在python类MyTester中的一些DLL代码。 为了validation目的,我需要在testing过程中logging一些testing数据,然后再做更多的处理。 因为我有很多testing_…文件,我想在testing中重用testing器对象的创build(MyTester的实例)。 由于testing者对象是获得对DLL的variables和函数的引用的对象,因此我需要将每个testing文件的DLLvariables列表传递给testing者对象(要logging的variables对于testing是相同的。 。文件)。 列表的内容应该用来logging指定的数据。 我的想法是这样做: import pytest class MyTester(): def __init__(self, arg = ["var0", "var1"]): self.arg = arg # self.use_arg_to_init_logging_part() def dothis(self): print "this" def dothat(self): print "that" # located in conftest.py (because other test will reuse it) @pytest.fixture() def tester(request): """ create tester object """ # how to use the list below […]

Django:没有指定主键创build灯具?

我对Django装置的一些误解是你必须指定每个模型的主键。 有什么办法可以创build灯具而不必为每一行指定一个主键?