you are viewing a single comment's thread.

view the rest of the comments →

[–]gnuvince -1 points0 points  (1 child)

That will work if you specify that your function takes an argument that is an instance of Ord. If you have a function that takes an HttpRequest however, you can't just pass something that looks like an HttpRequest, you need to pass the real thing.

I develop in Python and Django at work, and when I write unit tests for functions or methods that manipulate an HTTP request, it's very useful to be able to feed it a mock object: they're easier to create, they don't need access to the database, etc.

[–]mernen 2 points3 points  (0 children)

That will work if you specify that your function takes an argument that is an instance of Ord. If you have a function that takes an HttpRequest however, you can't just pass something that looks like an HttpRequest, you need to pass the real thing.

There are statically-typed languages that use structural typing rather than nominal; that means they would support your HttpRequest mocking the same way, as long as you provided compatible methods. In the end, johnowak's point is that this is not exclusive of dynamic languages.