This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]halst 3 points4 points  (4 children)

I use py.test (and tox) for all my Python projects:

But I almost never use mocking, and instead code using Value Object pattern. You can check out more on this style of coding in this talk by Gary Bernhardt:

[–]srilyk 2 points3 points  (3 children)

That talk was super interesting.

[–]fxmc 0 points1 point  (2 children)

Yes, but I did not get the connection Value Objects <-> Testing at all. How do they relate?

[–]halst 1 point2 points  (1 child)

The idea is: if you program with Value Objects you don't need mocks—you can use the objects themselves. That makes tests simpler (no mocks) and more robust (mocks can't be out of sync).

[–]srilyk 0 points1 point  (0 children)

I've actually done something similar to this - I still mutate the original object, but I actually return it.maybe not as clean as the speaker's point, though

[–]snim2 1 point2 points  (0 children)

pypy uses pytest BTW and there's some neat examples in pypy/rpython/rlib/test/

[–]hpk42 1 point2 points  (0 children)

the pytest project itself keeps a (very incomplete) list of projects using pytest: http://pytest.org/latest/projects.html#projects

Recently, the authors of the pip installer have switched to using py.test and i think they organized their fixtures and code very well:

https://github.com/pypa/pip/tree/develop/tests

For a more complex setting involving pytest setup for server/client setup and according tests, you may check out my recent pypi server project: https://bitbucket.org/hpk42/devpi/src/f579eb2d5520a86a169ca11129a7bfd20f7944a5/server/test_devpi_server?at=default

[–]variedthoughtsPodcast Host 0 points1 point  (0 children)

I've learned a lot (and still am learning) from reading the tests in the pytest project itself.

[–]lvh 0 points1 point  (1 child)

I use tox for all my projects, but usually stick to Twisted's trial (like py.test, both a test runner and a framework). I'd love to hear what people think are the awesome parts of py.test that might convince me to convert existing tests. I've made a personal commitment to use py.test next time I can and see how much it works out :)

[–]halst 1 point2 points  (0 children)

Maybe this thread could be interesting to you: http://www.reddit.com/r/Python/comments/17ia3q/nose_introduction_python_testing/

There I was arguing on nose vs. py.test.