3 ms·
1) don't use objects, use bare methods and don't mutate input data 2) `from collections import namedtuple` reinforces 1 3) nice lighweight tests, py.test or n
by sitkack 10y ago
1) don't use objects, use bare methods and don't mutate input data
2) `from collections import namedtuple` reinforces 1
3) nice lighweight tests, py.test or nose
4) integration tests so you can actually refactor w/o having to recode 100 unit tests
5) write as little code as possible
- cdent 10y ago+many to number 4. A super abundance of unit tests (especially if they use mocks) gives a false sense of security at the cost of high barriers to refactoring. Where's the win?
- mrfusion 10y agoCan you expand on 1 and 2?
- iampims 10y agoNot OP. 2) From the doc [1]: > Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index. They do act as immutable containers for related data. They are usually used to replace classes that don't have any behavior/methods. They avoid confusion by having a name, and named attributes. [1] https://docs.python.org/2/library/collections.html#collections.namedtuple https://docs.python.org/2/library/collections.html#collectio...
- mrfusion 10y agoAny advice on writing integration tests?
- olau 10y agoWrite them in terms of user requirements. When someone does X, they expect Y to happen. If a test breaks, it should mean that a user somewhere would think there's a problem. See for instance this: http://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf http://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.... You can write integration tests with the same tools as unit tests. Personally, I try to make sure all major paths are covered, but I won't test every little UI detail. It's faster to test those manually. But YMMV.
- mrfusion 10y agoAny advice on writing integration tests?