Skip to content

Commit

Permalink
concerning test method prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zackmdavis committed Oct 10, 2015
1 parent a8bbef4 commit 092f83b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 28 deletions.
11 changes: 11 additions & 0 deletions concerned_testrunner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

from django.test.runner import DiscoverRunner


class ConcernedTestLoader(unittest.TestLoader):
testMethodPrefix = "concerning"


class ConcernedTestRunner(DiscoverRunner):
test_loader = ConcernedTestLoader()
10 changes: 5 additions & 5 deletions core/tests/color_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@

class ColorTestCase(TestCase):

def test_can_diffract(self):
def concerning_diffraction(self):
self.assertEqual([127, 2, 255], diffract("7f02ff"))

def test_can_undiffract(self):
def concerning_undiffraction(self):
self.assertEqual("7f02ff", undiffract([127, 2, 255]))

def test_can_interpolate(self):
def concerning_interpolation(self):
self.assertEqual([127, 127, 127],
interpolate([0, 0, 0], [254, 254, 254], 0.5))

def test_can_interpolate_stop(self):
def concerning_stop_interpolation(self):
self.assertEqual("7f7f7f",
interpolate_stop({1: "000000", 3: "fefefe"}, 2))

class StyleTestCase(TestCase):

def test_can_populate_stops(self):
def concerning_stop_population(self):
self.assertEqual(
{-4: 'ff0000', -3: 'df001f', -2: 'bf003f', -1: '9f005f',
0: '7f007f', 1: '5f009f', 2: '3f00bf', 3: '1f00df', 4: '0000ff'},
Expand Down
38 changes: 19 additions & 19 deletions core/tests/view_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class SignupTestCase(TestCase):

def test_can_sign_up(self):
def concerning_signup(self):
response = self.client.post(
reverse('sign_up'),
{'username': "signup_testr",
Expand All @@ -23,7 +23,7 @@ def test_can_sign_up(self):
self.assertTrue(user_queryset.exists())
self.assertTrue(user_queryset[0].check_password("moeDukr(,rpdCesLlrq"))

def test_cannnot_claim_extant_username(self):
def concerning_the_inability_to_claim_extant_usernames(self):
f.FinetoothUserFactory.create(username="username_squatter")
response = self.client.post(
reverse('sign_up'),
Expand All @@ -36,7 +36,7 @@ def test_cannnot_claim_extant_username(self):
self.assertIn(b"A user with that username already exists.",
response.content)

def test_confirm_password_must_match(self):
def concerning_confirm_passwords_needing_to_match(self):
prior_user_count = FinetoothUser.objects.count()
response = self.client.post(
reverse('sign_up'),
Expand All @@ -50,7 +50,7 @@ def test_confirm_password_must_match(self):
self.assertEqual(prior_user_count, post_user_count)
self.assertEqual(422, response.status_code)

def test_required_fields(self):
def concerning_required_fields(self):
prior_user_count = FinetoothUser.objects.count()
response = self.client.post(
reverse('sign_up'),
Expand Down Expand Up @@ -81,13 +81,13 @@ def setUp(self):
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)

def test_user_can_tag_own_post(self):
def concerning_users_tagging_their_own_posts(self):
self.client.post(reverse('tag', args=(self.the_post.pk,)),
{'label': "taggable"})
tags = self.the_post.tag_set
self.assertTrue("taggable", tags.filter(label="taggable").exists())

def test_user_cannot_tag_post_of_other(self):
def concerning_users_inability_to_tag_posts_of_others(self):
response = self.client.post(
reverse('tag', args=(self.other_post.pk,)),
{'label': "untaggable"}
Expand All @@ -96,7 +96,7 @@ def test_user_cannot_tag_post_of_other(self):
tags = self.other_post.tag_set
self.assertEqual(0, tags.count())

def test_user_cannot_double_apply_same_tag(self):
def concerning_prohibition_of_double_tagging(self):
tags_before = self.the_post.tag_set.all()
response = self.client.post(
reverse('tag', args=(self.the_post.pk,)),
Expand All @@ -115,7 +115,7 @@ def setUpTestData(cls):
cls.the_user = f.FinetoothUserFactory.create()
cls.the_post = f.PostFactory.create()

def test_can_submit_comment(self):
def concerning_comment_submission(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -135,7 +135,7 @@ def test_can_submit_comment(self):
) + fragment_identifier
)

def test_against_html_injection(self):
def concerning_html_injection(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -146,7 +146,7 @@ def test_against_html_injection(self):
comment = self.the_post.comment_set.filter(commenter=self.the_user)[0]
self.assertNotIn("<textarea>", comment.content)

def test_do_not_panic_on_blank_comment(self):
def concerning_blank_comment_submissions(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -164,7 +164,7 @@ def setUpTestData(cls):
cls.the_user = f.FinetoothUserFactory.create()
cls.the_post = f.PostFactory.create(content="hello Django world")

def test_can_vote(self):
def concerning_suffrage(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -177,14 +177,14 @@ def test_can_vote(self):
self.assertEqual(response.status_code, 204)


def test_cannot_vote_if_not_logged_in(self):
def concerning_suffrage_of_undocumented_immigrants(self):
response = self.client.post(
reverse('vote', args=("post", self.the_post.pk)),
{'startIndex': 1, 'endIndex': 5, 'value': 1}
)
self.assertEqual(response.status_code, 401)

def test_cannot_submit_invalid_vote(self):
def concerning_hanging_chads(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -196,7 +196,7 @@ def test_cannot_submit_invalid_vote(self):
)
self.assertEqual(response.status_code, 400)

def test_one_user_one_vote(self):
def concerning_the_principle_of_one_user_one_vote(self):
self.client.login(
username=self.the_user.username, password=f.FACTORY_USER_PASSWORD
)
Expand All @@ -223,12 +223,12 @@ def setUpTestData(cls):
username="Not_Jennifer", password="shsk$&hfio"
)

def test_do_not_choke_on_nonexistent_user(self):
def concerning_nonexistent_users(self):
response = self.client.get(
reverse('show_profile', args=("nonexistent2507",)), follow=True)
self.assertContains(response, "That user does not exist.")

def test_can_edit_profile(self):
def concerning_profile_editing(self):
self.client.login(username="Jennifer_Userton", password="vmR9*sdfp[")
response = self.client.post(
reverse('edit_profile', args=("Jennifer_Userton",)),
Expand All @@ -244,7 +244,7 @@ def test_can_edit_profile(self):
self.assertEqual("Usertown, California",
the_user_transformed.location)

def test_cannot_edit_profile_not_ones_own(self):
def concerning_editing_the_profiles_of_others(self):
self.client.login(username="Jennifer_Userton", password="vmR9*sdfp[")
response = self.client.post(
reverse('edit_profile', args=("Not_Jennifer",)),
Expand All @@ -265,7 +265,7 @@ def setUpTestData(cls):
def setUp(self):
self.client.login(username="Jennifer_Userton", password="vmR9*sdfp[")

def test_new_post(self):
def concerning_new_posts(self):
new_post_title = "A very entertaining post"
response = self.client.post(
reverse('new_post'),
Expand All @@ -291,7 +291,7 @@ def setUpTestData(cls):
published_at=datetime.now()-timedelta(10-i)
)

def test_pagination(self):
def concerning_pagination(self):
with self.settings(POSTS_PER_PAGE=3):
pages = [self.client.get(reverse('home', args=(i,)))
for i in range(1, 5)]
Expand Down
8 changes: 4 additions & 4 deletions core/tests/votable_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def setUpTestData(self):
content = "*Hello* [Python](python.org) world"
self.tag_skeptic = Tagnostic(content)

def test_feeding(self):
def concerning_feeding(self):
self.assertEqual(
self.tag_skeptic.content,
[('p', {}), ("em", {}), "Hello", ("/em",), " ",
('a', {'href': 'python.org'}), "Python", ("/a",),
" world", ('/p',)]
)

def test_plaintext(self):
def concerning_plaintext(self):
self.assertEqual(self.tag_skeptic.plaintext(), "Hello Python world")

class ScoringTestCase(TestCase):
Expand All @@ -40,7 +40,7 @@ def setUpTestData(self):
start_index=i, end_index=10
)

def test_scored_plaintext(self):
def concerning_scored_plaintext(self):
self.assertEqual(
self.the_post.scored_plaintext(),
(('f', 1, 0), ('r', 2, 0), ('i', 3, 0), ('e', 4, 0), ('n', 5, 0),
Expand All @@ -62,7 +62,7 @@ def setUpTestData(self):
start_index=indices[0], end_index=indices[1]
)

def test_rendering(self):
def concerning_rendering(self):
self.assertHTMLEqual(
self.the_post.render(),
"""<p>
Expand Down
2 changes: 2 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@
}
}

TEST_RUNNER = 'concerned_testrunner.ConcernedTestRunner'

POSTS_PER_PAGE = 15

0 comments on commit 092f83b

Please sign in to comment.