python - Nose - Is it possible to stub a class constant? -
Nandbb in the nose structure here
Looking at the docs for the unit. Mock, I do not think a clear way of a variable is to test a class with the horses I declared. A constant is a very large int and for testing purposes, I want to change it with very small int.
My understanding is that you only fashion (with @ patch decorator) and not a variable.
Is it possible, and if so, how?
You can use the patch decorator to constantly change eg .:
& gt; & Gt; & Gt; Import Mock & gt; & Gt; & Gt; Square Fu (object): ... bar = 1000000 ... & gt; & Gt; & Gt; With Mock.patch.object (Foo, 'bar', 10): ... print (Foo.bar) ... 10 >> gt; & Gt; Specifically, look for(or anynewforpatch patch) for print (Foo.bar) 1000000
/ Code> items in the family) ...
I am on dragon 2.x where duplicate was still a third-party module. Import code that can be imported from with the duplicate code should have the above code work for you.
Comments
Post a Comment