Skip to content
Advertisement

Tag: testing

how do I efficiently test this Django model?

I’m building an authentication system for a website, I don’t have prior test experience with Django. I have written some basic tests. the model, and model manager, and my tests, fortunately all the passes, and my question is, are these tests overdone or underdone or normal? What should be tested in a model? is there any procedure missing? anything wrong

What’s the idea behind pytest-cache?

pytest-cache It seems to be a tool to cache func/args->result pairs and even persist them between testsuite-runs. Which seems like a great idea to speed things up. However I haven’t noticed any mention of automatically detecting a change of a function source code and invalidating corresponding cache entries. That seems to defeat the purpose of running the test suite, because

Trying to mock datetime.date.today(), but not working

Can anyone tell me why this isn’t working? Perhaps someone could suggest a better way? Answer There are a few problems. First of all, the way you’re using mock.patch isn’t quite right. When used as a decorator, it replaces the given function/class (in this case, datetime.date.today) with a Mock object only within the decorated function. So, only within your today()

How to use `pytest` from Python?

I’m working in a project that recently switched to the pytest unittest framework. I was used to calling my tests from Eclipse, so that I can use the debugger (e.g. placing breakpoints to analyze how a test failure develops). Now this is no longer possible, since the only way to run the tests is via the command line blackbox. Is

Python unit test with base and sub class

I currently have a few unit tests which share a common set of tests. Here’s an example: The output of the above is: Is there a way to rewrite the above so that the very first testCommon is not called? EDIT: Instead of running 5 tests above, I want it to run only 4 tests, 2 from the SubTest1 and

can’t see records inserted by django test case

I’m trying to provide integration to my django application from subversion through the post commit hook. I have a django test case (a subclass of unittest.TestCase) that (a) inserts a couple of records into a table, (b) spawns an svn commit, (c) svn commit runs a hook that uses my django model to look up info. I’m using an sqlite3

Running unit tests on nested functions

I come from the Java world, where you can hide variables and functions and then run unit tests against them using reflection. I have used nested functions to hide implementation details of my classes so that only the public API is visible. I am trying to write unit tests against these nested functions to make sure that I don’t break

Advertisement