What are the best practices for testing “different layers” in Django? [closed]

UPDATE 08-07-2012 I can tell you my practices for unit testing that are working pretty well for my own ends and I’ll give you my reasons: 1.- Use Fixtures only for information that is necessary for testing but is not going to change, for example, you need a user for every test you do so … Read more

Py.test: parametrize test cases from classes

If you subclass from unittest.TestCase, your test methods cannot have additional arguments. If you simply subclass from object, it will work (though you’ll have to use regular assert statements instead of the TestCase.assertEqual methods. import unittest import pytest class TestCase(object): @pytest.mark.parametrize(“test_input,expected”, [ (“3+5”, 8), (“2+4”, 6), (“6*9”, 42), ]) def test_1(self, a, b): assert eval(a) … Read more

Testing d3 (and other SVG based) Web Applications

The example you give are for testing the graphical output. For this you can use a screenshot diff tool like PhantomCSS, Sikuli or roll-up your own with Resemble.js. But if your question is more genrally about testing D3.js/SVG-based apps, as the title implies, you should look at the D3 test suite. Most tests don’t even … Read more

Writing “unit testable” code?

TDD — write the tests first, forces you to think about testability and helps write the code that is actually needed, not what you think you may need Refactoring to interfaces — makes mocking easier Public methods virtual if not using interfaces — makes mocking easier Dependency injection — makes mocking easier Smaller, more targeted … Read more