Skip to content

Instantly share code, notes, and snippets.

@bitprophet
Last active December 17, 2015 00:29
Show Gist options
  • Save bitprophet/5521430 to your computer and use it in GitHub Desktop.
Save bitprophet/5521430 to your computer and use it in GitHub Desktop.
The problem with unittest

(Using fabric/fabric as an example of a unittest style project with a complex, nontrivial test suite)

» find tests -type f -maxdepth 1 -mindepth 1 -name "*.py" | wc -l
    18
» find tests -type f -maxdepth 1 -mindepth 1 -name "test_*.py" | wc -l
    13

75% of the files in my tests folder are tests, yet they must be named test_.

» grep -inr "class " tests/test_* | wc -l
    29
» grep -inr "class Test" tests/test_* | wc -l
    23

80% of the classes in my tests folder, in my files named test_*, must be named Test*.

» grep -inr "def " tests/test_* | wc -l
    383
» grep -inr "def test_" tests/test_* | wc -l
    285

75% of the functions or methods in my tests folder, in my files named test_*, most of which are inside classes named Test*, must be named test_*.

That is the problem with unittest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment