[{"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606041.950598, "message": "I write my tests using unittest (unittest2 if given the choice), I use Mock regularly now (used mox & pymock before), and only occasionally use doctest.", "group_id": 292, "id": 205610}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606322.9780991, "message": "seems most everyone else I talk to about testing starts off with functional tests, and honestly most of them *only* do functional/acceptance tests.", "group_id": 292, "id": 205665}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298605971.919266, "message": "I'm writing a lot of tests lately, mostly for existing code that doesn't have tests, or adding tests to existing suites to increase coverage. Thought I'd start a topic to share/get ideas, links, etc about testing tools & methodologies, specifically in the context of coding Python.", "group_id": 292, "id": 205595}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606131.3029139, "message": "I use nose --with-coverage to *run* my tests & get a ballpark coverage number, but I'm finding that coverage numbers are no way to gauge progress or completeness for tests.", "group_id": 292, "id": 205625}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606207.5683751, "message": "From everyone I've spoken to, I seem to be a testing oddball in that I started with unit tests and still write unit tests for everything before I move on to functional & acceptance tests.", "group_id": 292, "id": 205642}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606251.4486771, "message": "for me unit tests are actually more convenient because you don't have any requirements except for the code itself, so there's no external services to set up. I can do it all on a plane without starting daemons and the like.", "group_id": 292, "id": 205652}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606355.4407201, "message": "I also sometimes run across people talking about testing and using the term \"unit test\" for things that aren't unit tests at all.", "group_id": 292, "id": 205670}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298606400.057404, "message": "What tools/methodologies are you using? What's worked/not worked for you?", "group_id": 292, "id": 205678}, {"user_id": 6543, "stars": [{"date_created": 1298608334.440819, "user_id": 7376}, {"date_created": 1298635489.500206, "user_id": 978}, {"date_created": 1298713625.6980591, "user_id": 12126}], "topic_id": 8972, "date_created": 1298607047.953759, "message": "\"i don't always write unit tests, but when i do, i follow http://docs.pylonsproject.org/community/testing.html\"", "group_id": 292, "id": 205739}, {"user_id": 6543, "stars": [], "topic_id": 8972, "date_created": 1298607209.555552, "message": "(i also share your oddballness, i write mostly unit tests; it appears to be a rarity... understandably, because often you have to write functests anyway and nobody has the patience to actually write both)", "group_id": 292, "id": 205748}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298610018.1311419, "message": "I've been struggling with the idea of writing unit tests for the distributed system I work on every day... Certain servers are responsible for certain things, and a lot of our code relies on things that are produced on Servers B, C, and D but consumed on Server A. Likewise, Server A often produces things that must be consumed by Servers B, C, and D (either all at the same time or one at a time, depending on the task).", "group_id": 292, "id": 205997}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298610027.5457759, "message": "any tips for writing unit tests for things like that?", "group_id": 292, "id": 205998}, {"user_id": 7, "stars": [{"date_created": 1298827977.5752051, "user_id": 261}], "topic_id": 8972, "date_created": 1298612637.3393281, "message": "Time and a place for each", "group_id": 292, "id": 206170}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298612670.5365629, "message": "so you get a lot more bang for your buck testing the full line", "group_id": 292, "id": 206174}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298611752.441668, "message": "I'd be interested in whether people who do a lot of unit testing agree or disagree with that.", "group_id": 292, "id": 206088}, {"user_id": 214, "stars": [{"date_created": 1298611908.7121339, "user_id": 5778}, {"date_created": 1298626767.2314701, "user_id": 5367}, {"date_created": 1298824039.4762421, "user_id": 205}], "topic_id": 8972, "date_created": 1298611722.68506, "message": "It seems to me, completely anecdotally, that unit tests are more of a way of writing and designing code, whereas functional tests are more useful in actually catching bugs and regressions, and as a safety net for refactoring.", "group_id": 292, "id": 206083}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613212.787791, "message": "Currently trying to decide whether to stick with unittest2 or dive into py.test for testing a new project.", "group_id": 292, "id": 206211}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298611987.045413, "message": "I mean, seriously, how are you supposed to compose a test for when there's a network failure?", "group_id": 292, "id": 206120}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298612659.2127819, "message": "So for example for Django's ORM it's waaaay easier to just functional test it, plus none of the internal APIs are stable", "group_id": 292, "id": 206173}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613194.5793581, "message": "@alex To change the subject (but only slightly) how do you feel about py.test having worked on PyPy a fair amount?", "group_id": 292, "id": 206208}, {"user_id": 214, "stars": [{"date_created": 1298613345.8691831, "user_id": 7}], "topic_id": 8972, "date_created": 1298613331.1020751, "message": "Re \"time and place for each,\" mostly it seems to me there are the occasional subsystems that are so nicely isolated with clearly defined inputs and outputs that almost anyone who does testing would naturally unit-test them. They just lend themselves to it. I'm kind of excluding those from consideration. It seems some people find benefit in unit-testing the kind of code that doesn't lend itself to it so obviously, and I'm working my head around the benefits in those cases.", "group_id": 292, "id": 206228}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613386.0022759, "message": "Yeah, it's pretty clear to me that I'll enjoy writing tests more in py.test.", "group_id": 292, "id": 206234}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613440.5320051, "message": "@carljm magic. just magic.", "group_id": 292, "id": 206243}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613456.7601061, "message": "It'd be nice if pytest_funcarg was replaced with a real registration system", "group_id": 292, "id": 206245}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298612061.9466641, "message": "*sigh* I guess I'll ponder this more another time... I'm sleepy", "group_id": 292, "id": 206131}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298612064.599076, "message": "night!", "group_id": 292, "id": 206133}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613468.5313461, "message": "then the only magic would be introspecting the arguments that a test function takes", "group_id": 292, "id": 206249}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298611798.764936, "message": "I'm one of those who tends to mostly write functional/acceptance tests.", "group_id": 292, "id": 206095}, {"user_id": 214, "stars": [{"date_created": 1298643866.583709, "user_id": 4156}], "topic_id": 8972, "date_created": 1298611808.716727, "message": "I want my tests to tell me whether the system works.", "group_id": 292, "id": 206098}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298612706.5912189, "message": "OTOH in PyPy we're writing a new system for testing the intermediate code the JIT produces, so we've got a pattern matching system that compares expected with actual, and that's carefully unittested", "group_id": 292, "id": 206176}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298611923.717927, "message": "@carljm yes, I suppose that is the traditional meaning of unit testing, huh...", "group_id": 292, "id": 206109}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298611958.677531, "message": "and that's what I want to avoid--bugs in the things that \"require the wire\"", "group_id": 292, "id": 206116}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298612015.2130499, "message": "meh", "group_id": 292, "id": 206125}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298611936.9539549, "message": "@carljm I agree.", "group_id": 292, "id": 206112}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298611922.0952761, "message": "And so many real-life bugs happen at the integration points, that functional tests just seem more useful for that.", "group_id": 292, "id": 206108}, {"user_id": 7, "stars": [{"date_created": 1298613367.3015311, "user_id": 214}, {"date_created": 1298635630.281199, "user_id": 978}], "topic_id": 8972, "date_created": 1298613264.5619979, "message": "@carljm big fan, the *only* downside is that you shouldn't do things like `assert foo.read() == \"abc\"`, you need to do `r = foo.read(); assert r == \"abc\"` because you don't want things with side effects to be executed 2x if the test fails", "group_id": 292, "id": 206221}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613406.8494921, "message": "There's a lot of non-obvious stuff that goes on.", "group_id": 292, "id": 206237}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613529.0488341, "message": "Similar to pytest_funcargs magic?", "group_id": 292, "id": 206258}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298612013.7782819, "message": "or when your firewall rules are out of sync", "group_id": 292, "id": 206124}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298612062.4576089, "message": "hehe", "group_id": 292, "id": 206132}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613504.191386, "message": "Although fun fact, Django's got something simliar going on", "group_id": 292, "id": 206253}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298612760.7033379, "message": "Somehow I feel like I just insulted Django's testing, but I really didn't mean to", "group_id": 292, "id": 206179}, {"user_id": 7, "stars": [{"date_created": 1298613370.137275, "user_id": 214}], "topic_id": 8972, "date_created": 1298613288.4930899, "message": "but it's sooo much nicer to write your tests as `assert \"x\" in result` than `self.assertIn(\"x\", result)`, and the tracebacks are nicer than nose", "group_id": 292, "id": 206222}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613304.346822, "message": "plus there's some very architecture for plugins and such", "group_id": 292, "id": 206224}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613399.009274, "message": "Just wondering how much someone who doesn't grok py.test will enjoy potentially having to maintain them.", "group_id": 292, "id": 206235}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613422.7286911, "message": "pytest_funcarg__something maps to the \"something\" argument to my test function how, again?", "group_id": 292, "id": 206240}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613323.1657951, "message": "you can do stuff like easily autogenerate tests, mark them for stuff, funcargs are neat, etc.", "group_id": 292, "id": 206226}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613424.8555191, "message": "true, py.test really is magic, but it's so nice :/", "group_id": 292, "id": 206241}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298613466.6960161, "message": "Yeah.", "group_id": 292, "id": 206248}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613537.6290381, "message": "no to the arg checking part", "group_id": 292, "id": 206261}, {"user_id": 7, "stars": [], "topic_id": 8972, "date_created": 1298613542.629519, "message": "in @simpletag", "group_id": 292, "id": 206263}, {"user_id": 12907, "stars": [], "topic_id": 8972, "date_created": 1298625845.7785759, "message": "@chrismcdonough Good on you - unit tests don't take long and they're a great foundation for your functional tests. And while coverage is only an indicator, the lines that aren't covered are a really good pointer - particularly if you've been staring at a piece of code for ages.", "group_id": 292, "id": 206759}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298642087.652699, "message": "@codekoala: You never want to use the real network in your unit tests, because you don't want real network failures to tell you that your code is broken (even if your code handles network failures correctly, that doesn't mean that a unit test for a success case is going to pass when the network is down). Similarly, you always want to write and run the tests for your code's handling of network failures, even when your network is working. Plus, the real network is slow and you want your tests to be as fast as possible. And resources on a real network can change unexpectedly (particularly if they're not directly under your control). So, fake the network.", "group_id": 292, "id": 207828}, {"user_id": 5639, "stars": [{"date_created": 1298662212.7957089, "user_id": 5778}], "topic_id": 8972, "date_created": 1298645372.7485809, "message": "I also tend to cast a bit of a suspicious eye on functional tests, because (is this a trend?) they tend to cover the \"expected\" case, as if the question they want answered is \"In a perfect world, does my code work?\", and that's really a small fraction of the total picture I'm looking to get of the code I work on. That said, that's a human limitation, and not a limitation of functional tests, which I view as married to unit tests: neither by themselves represents a complete testing regimen.", "group_id": 292, "id": 208229}, {"user_id": 214, "stars": [{"date_created": 1298645881.195503, "user_id": 978}, {"date_created": 1298662251.592582, "user_id": 5778}, {"date_created": 1298694133.489285, "user_id": 4156}], "topic_id": 8972, "date_created": 1298645758.5120571, "message": "@jonesy The way I tend to write tests initially is documentation-driven. If I document that a public API works a certain way, I want tests that verify it actually does work when used that way. So yeah, that's testing the \"expected cases,\" but to me it seems like the natural place to start. Then if I add a regression test whenever I catch and fix a bug, the unexpected cases get filled in over time, as they reveal themselves.", "group_id": 292, "id": 208272}, {"user_id": 214, "stars": [{"date_created": 1298645878.8756449, "user_id": 978}], "topic_id": 8972, "date_created": 1298645842.1348109, "message": "Not to say that I won't also initially write tests for unexpected cases that I have in mind. But trying to think of every possible unexpected case when I first write tests is a perfectionist burden that just takes too long.", "group_id": 292, "id": 208290}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298645239.467592, "message": "I consider each kind of test \"necessary but not sufficient\". Functional tests will catch a completely different class of bugs from unit tests (though there's inevitably some overlap in the bugs they'll catch in a significant system). I just find unit tests far more convenient to write, and I can gain a high level of confidence through using them. For example, if I want to test how my code handles a network outage or a cache miss, it seems a lot more logical and convenient to mock out the cache or network handles and have them raise an error or return None than to actually figure out how to emulate a miss or outage with live infrastructure. Unit tests have the nice quality of being self-contained with no external resource dependencies.", "group_id": 292, "id": 208207}, {"user_id": 978, "stars": [], "topic_id": 8972, "date_created": 1298645676.9386749, "message": "@jonesy: I am beginning to shy away from unit tests mostly due to mocking. I am always worried that I will mistype a function name both in the code and on mock object in the test. This would allow my test to pass, but in reality the code is broken. Do you have any idea's on how to get around that feeling?", "group_id": 292, "id": 208260}, {"user_id": 978, "stars": [], "topic_id": 8972, "date_created": 1298646834.3017819, "message": "@jpcalderone: zope scares me, but you have pointed me in the right direction. Thanks.", "group_id": 292, "id": 208469}, {"user_id": 214, "stars": [{"date_created": 1298646078.3348849, "user_id": 978}], "topic_id": 8972, "date_created": 1298645961.191864, "message": "Actually, I think that's the problem I have with unit tests in general. I already tend towards perfectionism, and writing unit tests tends to drive me even further into spiraling loops of obsessing over details of internal code and API design. Maybe that's a good thing - but I do want to ship. And for me, writing high-level functional tests that document how I want the system to work helps me do that.", "group_id": 292, "id": 208310}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298647900.2601631, "message": "mock allows you to create mock objects with the same interface as the object / class they're mocking through the spec argument", "group_id": 292, "id": 208674}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648151.4901919, "message": "@jpcalderone where a method is mocked with mocksignature you use it in a slightly different way", "group_id": 292, "id": 208728}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298648137.646353, "message": "You can do the assertion yourself immediately afterwards, but that doesn't keep you safe in the case where you change the signature of the real implementation and forget about the mock in your test.", "group_id": 292, "id": 208724}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298647341.882036, "message": "@jpcalderone I was never under the impression that it would be possible to cover everything ;-) The tradeoff you're talking about makes some sense, but there's still something about making it in practice that triggers my YAGNI-detector...", "group_id": 292, "id": 208533}, {"user_id": 5701, "stars": [{"date_created": 1298647192.522393, "user_id": 214}], "topic_id": 8972, "date_created": 1298646980.132796, "message": "carljm: No one covers all of the cases of their code. 100% line coverage isn't every case. 100% branch coverage isn't every case. 100% MC/DC might be getting close, but I'm sure there are cases it misses too. The most fanatical tests rarely cover every case (if they ever do). So it's not a question of whether to cover everything or not - you won't. It's a question of trading time spent now making sure things work vs time spent later trying to figure out why things don't work. Time spent now is a great investment, because it's cheaper to unit test than to debug (one of the few things about software development that there are actual studies to back up), but you're never going to be 100% sure you won't have to debug something later.", "group_id": 292, "id": 208492}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298647920.3758199, "message": "only methods / attributes on SomeClass will be available on the mock", "group_id": 292, "id": 208681}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298647941.01509, "message": "@jpcalderone mocksignature does that", "group_id": 292, "id": 208693}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298647908.566149, "message": "Mock(spec=SomeClass)", "group_id": 292, "id": 208677}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298647977.6099491, "message": "@jpcalderone that creates functions that delegate to a mock, where the function has the same signature as the function (or Class.__init__ or thing.__call__) they are mocking", "group_id": 292, "id": 208702}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648015.6805401, "message": "@jpcalderone its more useful where I want a mocked function / method to be a real function object", "group_id": 292, "id": 208707}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648072.207938, "message": "mock.method.assert_called_with(some, args)", "group_id": 292, "id": 208714}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298647928.5520771, "message": "@voidspace: Does that check method signatures as well?", "group_id": 292, "id": 208685}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648001.155246, "message": "@jpcalderone but as mocks allow you to verify they have been called in the right way anyway I very rarely use mocksignature", "group_id": 292, "id": 208705}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298648080.8763089, "message": "@voidspace: Hm, that's weird. Wouldn't it be more helpful and less typing all around if Mock(spec=SomeClass) just created methods that checked the signature?", "group_id": 292, "id": 208717}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648212.262939, "message": "@jpcalederone and spec was pre-existing, so changing spec to use mocksignature would break backwards compatibility with code already using spec", "group_id": 292, "id": 208730}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648184.2211499, "message": "@jpcalderone thing.method.mock.assert_called_with(...) (where method is the function mocked with mocksignature and method.mock is the mock it is delegating to)", "group_id": 292, "id": 208729}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298648237.3862469, "message": "@jpcalderone I could add a new option that does that and deprecate spec I guess. I'll consider that for a future release.", "group_id": 292, "id": 208732}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652295.7184689, "message": "but even without that there are better patterns for handling it", "group_id": 292, "id": 209453}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652682.205061, "message": "@voidspace agreed, but this seems to be telling people up front \"aw, don't worry about all that\" http://docs.pylonsproject.org/community/testing.html#tips-for-avoiding-bad-unit-tests", "group_id": 292, "id": 209523}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652635.6376419, "message": "but like all principles turning it into a rule is dumb", "group_id": 292, "id": 209509}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652643.204226, "message": "but yeah, it's still a good principle", "group_id": 292, "id": 209510}, {"user_id": 214, "stars": [], "topic_id": 8972, "date_created": 1298652083.1643231, "message": "@jonesy That example isn't super-clear, but it's not nonsensical. The implication is that FooClass can be instantiated with a Qux instance as its single argument. The point is about when and where the qux module is imported.", "group_id": 292, "id": 209417}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651701.9723339, "message": "GAH. http://docs.pylonsproject.org/community/testing.html#guideline-minimize-module-scope-dependencies", "group_id": 292, "id": 209375}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652747.308111, "message": "I use DRY if it doesn't reduce readability, cause confusion, or reduce the isolation level of my tests.", "group_id": 292, "id": 209539}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652213.5440979, "message": "I have to admit, I don't actually use most of those guidelines in my tests.", "group_id": 292, "id": 209439}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652294.6592081, "message": "oh, they don't explain that. And it's not the case for my testing framework.", "group_id": 292, "id": 209452}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652252.3143041, "message": "the problem is that with some test frameworks a test module failing to import can *kill* the whole test run and not just show failing tests", "group_id": 292, "id": 209443}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652267.7707551, "message": "that's the problem they're trying to solve", "group_id": 292, "id": 209446}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652156.5077541, "message": "those guidelines suck rocks", "group_id": 292, "id": 209430}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652175.127501, "message": "@carljm yeah, got it - thanks. So, then, the idea would be that even if every method in the test class uses qux, they'd all individually import it? So if it's not there, all tests fail. So in that case, what's gained?", "group_id": 292, "id": 209433}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652176.701407, "message": "there are better ways of handling imports that may fail", "group_id": 292, "id": 209435}, {"user_id": 15977, "stars": [{"date_created": 1298652658.174072, "user_id": 214}], "topic_id": 8972, "date_created": 1298652652.4237511, "message": "I do tend to repeat myself more in tests than in production code", "group_id": 292, "id": 209514}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651576.16292, "message": "@chrismcdonough maybe I need more coffee, but this section makes zero sense to me: http://docs.pylonsproject.org/community/testing.html#rule-never-import-the-module-under-test-at-test-module-scope Specifically, it defines a '_getTargetClass' method that gets a very specific class, and then the test method winds up trying to use it to create a completely different specific class. As far as the overarching philosophy, I'm not really sold, but maybe because I separate my tests for different modules into different files (and maybe that's somehow no preferable? wfm)", "group_id": 292, "id": 209356}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651692.9249101, "message": "@chrismcdonough wrong link. I meant this one: @chrismcdonough", "group_id": 292, "id": 209374}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651754.0067921, "message": "@chrismcdonough wrong link, I meant http://docs.pylonsproject.org/community/testing.html#guideline-minimize-module-scope-dependencies", "group_id": 292, "id": 209384}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651725.317281, "message": "and now I forgot the freaking name. Convore, help me out! I need to edit messages!", "group_id": 292, "id": 209381}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298651763.4643619, "message": "there. Turns out I *did* need more coffee.", "group_id": 292, "id": 209385}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652286.298775, "message": "unittest(2) test discovery would turn the import failure into a single failure anyway", "group_id": 292, "id": 209450}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652539.705307, "message": "I specifically don't subscribe to the notion that DRY is bad (or that not practicing it is forgivable) in unit tests either. Unit tests are still code. If you can reduce it without screwing up your tests, do it, I say.", "group_id": 292, "id": 209493}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298652319.664742, "message": "yeah, nose will fail for each test as well.", "group_id": 292, "id": 209459}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652755.6040249, "message": "sounds good", "group_id": 292, "id": 209541}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652625.7435219, "message": "well, DRY is a good principle", "group_id": 292, "id": 209507}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652705.5406921, "message": "yeah", "group_id": 292, "id": 209528}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298652753.5452771, "message": "right", "group_id": 292, "id": 209540}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298663215.4627981, "message": "@codekoala if you're unit testing, you either mock the object that deals with the network, or better, the higher level object that would interface with the network (in which case you don't need to mock network drivers. Mock as close to your code under test as possible). You make that mock object return some dummy data that you want to test your code's response to. So if you're calling myinstance.get_network_data('/foo'), you'd mock myinstance.get_network_data and tell it to return whatever you want.", "group_id": 292, "id": 210848}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298662543.9606171, "message": "@jpcalderone how does one fake a network when the other side of the network connection is responsible for manipulating data?", "group_id": 292, "id": 210741}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298667672.7196009, "message": "@jonesy thanks for that description. my head hurts.", "group_id": 292, "id": 211250}, {"user_id": 5778, "stars": [], "topic_id": 8972, "date_created": 1298667757.473779, "message": "not because of your description, but because of all the stuff the mock object would have to take into consideration to truly mock things returned by our code....", "group_id": 292, "id": 211259}, {"user_id": 14356, "stars": [], "topic_id": 8972, "date_created": 1298668743.7778289, "message": "But in case of transactional systems, it is not possible to run a test with one set of data more than once as the test \"gets used up\". So I set up tests using data already in the system to see if it will fail for all kinds bad or used up data I can think of. The end to end test is still done manually as currently it requires a brain to figure out what should become of data once it gets into the system. But now we are only looking at good data (unless we have missed bad data and then it adds to the test cases).", "group_id": 292, "id": 211374}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298668748.3592219, "message": "record and replay transactions", "group_id": 292, "id": 211376}, {"user_id": 14356, "stars": [], "topic_id": 8972, "date_created": 1298668511.8284659, "message": "For systems that have distinct parts, say a part collects data from remote resource and another does processing, I use a man in the middle method. For testing the remote resource, it is more of testing if the format and data is good and may be compared with the source to the remote (if possible).", "group_id": 292, "id": 211350}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298668752.2576571, "message": "run a local server", "group_id": 292, "id": 211377}, {"user_id": 6543, "stars": [], "topic_id": 8972, "date_created": 1298698736.5231161, "message": "while those guidelines may suck rocks, they're better than having no guidelines at all i think", "group_id": 292, "id": 212882}, {"user_id": 16058, "stars": [], "topic_id": 8972, "date_created": 1298724554.124263, "message": "@chrismcdonough, suck what? Are you sure there isn't a typo? :-)", "group_id": 292, "id": 213949}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298724379.697221, "message": "I disagree that bad advice is better than no advice. :-)", "group_id": 292, "id": 213935}, {"user_id": 6543, "stars": [{"date_created": 1298740134.6266201, "user_id": 3617}, {"date_created": 1298748239.360183, "user_id": 214}, {"date_created": 1298828381.8815761, "user_id": 261}, {"date_created": 1298891396.411762, "user_id": 978}], "topic_id": 8972, "date_created": 1298740088.9213009, "message": "got a link to better ones?", "group_id": 292, "id": 214913}, {"user_id": 14356, "stars": [], "topic_id": 8972, "date_created": 1298820683.5931671, "message": "@voidspace how would you suggest to proceed after recording a transaction? Esp when the data gets inserted and has to be unique? In this case I am testing on the dev server,", "group_id": 292, "id": 217581}, {"user_id": 11592, "stars": [], "topic_id": 8972, "date_created": 1298828982.724133, "message": "I had jenkins-ci installed today in it's *awesome*! One simple \u00abhg push\u00bb and it fires up testing tons of stuff, collecting neat metrics: nosetests, coverage, pylint. And can bash unruly developers with jabber messages (ashaming them in MUCs too!). Totally made my day.", "group_id": 292, "id": 218609}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298831739.256165, "message": "For those interested in mocking libraries for Python, here's a comparison page with *some* comparisons between several", "group_id": 292, "id": 218934}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298831741.202301, "message": "http://www.voidspace.org.uk/python/mock/compare.html", "group_id": 292, "id": 218935}, {"user_id": 15977, "stars": [], "topic_id": 8972, "date_created": 1298831755.2179379, "message": "I'd really like MiniMock examples if anyone cares to do them...", "group_id": 292, "id": 218937}, {"user_id": 11592, "stars": [{"date_created": 1298833151.975836, "user_id": 16058}], "topic_id": 8972, "date_created": 1298832802.0969651, "message": "Need to test django apps and don't want to bother with fixtures? Try django-any! https://github.com/kmmbvnr/django-any", "group_id": 292, "id": 219126}, {"user_id": 5639, "stars": [], "topic_id": 8972, "date_created": 1298647350.33829, "message": "@taharp @jpcalderone for verifying interfaces, I use mock.Mock objects and instantiate them by passing in the class to be mocked. If my test code, or the code under test, calls something on that mock that doesn't exist in the real class, it'll raise an exception. Is there something more you're looking for? (Mock class for reference: http://www.voidspace.org.uk/python/mock/mock.html#mock.Mock )", "group_id": 292, "id": 208535}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298647097.3811159, "message": "@taharp: Don't be too scared. zope.interface isn't anything like the full Zope project. :) It's a tiny corner, distributed separately, that you can learn and use without getting eaten by Zope.", "group_id": 292, "id": 208511}, {"user_id": 5701, "stars": [], "topic_id": 8972, "date_created": 1298646616.8478589, "message": "@taharp: You're looking for \"verified fakes\". If you mock something, then you should also have tests that assert it is sufficiently similar to the real implementation. There are lots of ways to go about this, one way I tend to use is zope.interface.verify.", "group_id": 292, "id": 208438}]