Created
April 28, 2010 15:44
-
-
Save justinabrahms/382306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestActiveField(object): | |
models_to_test = ['Model1', 'Model2', 'foo'] | |
def test_valid_choice(self): | |
for model in self.models_to_test: | |
yield self.check_valid_choice_for_active_field, model | |
def check_valid_choice_for_active_field(self, model): | |
# implement test logic here | |
assert 'foo' != model, "Model was %s" % model | |
# | |
# results in: | |
# | |
# views.base.TestActiveField.test_valid_choice('Model1',) ... ok | |
# views.base.TestActiveField.test_valid_choice('Model2',) ... ok | |
# views.base.TestActiveField.test_valid_choice('foo',) ... FAIL | |
# | |
# ====================================================================== | |
# FAIL: views.base.TestActiveField.test_valid_choice('foo',) | |
# ---------------------------------------------------------------------- | |
# Traceback (most recent call last): | |
# File "/home/jlilly/.virtualenvs/dashboard/lib/python2.5/site-packages/nose-0.11.2-py2.5.egg/nose/case.py", line 183, in runTest | |
# self.test(*self.arg) | |
# File "/home/jlilly/src/dashboard/tests/views/base.py", line 13, in check_valid_choice_for_active_field | |
# assert 'foo' != model, "Model was %s" % model | |
# AssertionError: Model was foo | |
# | |
# ---------------------------------------------------------------------- | |
# Ran 3 tests in 0.002 seconds | |
# FAILED (failures=1) |
You get every single case as a failure or success.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why is that better than: