Anonymous avatar Anonymous committed 477a7df

Since pinocchio is out, we don't need TestCaseWithSpec anymore.

Comments (0)

Files changed (3)

tests/_test_case_with_spec.py

-import re
-import unittest
-
-def remove_leading(needle, haystack):
-    """Remove leading needle string (if exists).
-
-    >>> remove_leading('Test', 'TestThisAndThat')
-    'ThisAndThat'
-    >>> remove_leading('Test', 'ArbitraryName')
-    'ArbitraryName'
-    """
-    if haystack[:len(needle)] == needle:
-        return haystack[len(needle):]
-    return haystack
-
-def camel2word(string):
-    """Covert name from CamelCase to "Normal case".
-
-    >>> camel2word('CamelCase')
-    'Camel case'
-    >>> camel2word('CaseWithSpec')
-    'Case with spec'
-    """
-    def wordize(match):
-        return ' ' + match.group(1).lower()
-
-    return string[0] + re.sub(r'([A-Z])', wordize, string[1:])
-
-def complete_english(string):
-    """
-    >>> complete_english('dont do this')
-    "don't do this"
-    >>> complete_english('doesnt is matched as well')
-    "doesn't is matched as well"
-    """
-    return string.replace('dont', "don't").replace('doesnt', "doesn't")
-
-def underscore2word(string):
-    return string.replace('_', ' ')
-
-class TestCaseWithSpec(unittest.TestCase):
-    def shortDescription(self):
-        return "%s %s" % (getattr(self, 'context', None) or camel2word(remove_leading('Test', self.__class__.__name__)),
-                          complete_english(underscore2word(remove_leading('test_', getattr(self, '_TestCase__testMethodName')))))

tests/test_store.py

 import time
 import unittest
 
-from _test_case_with_spec import TestCaseWithSpec
 from mock import Mock, ReturnValues
 import _path_setup
 
 ## Unit tests.
 ################################################################################
 
-class TestStoreInit(TestCaseWithSpec):
-    context = "Method Store.__init__()"
+class TestStoreInit(unittest.TestCase):
+    "Method Store.__init__()"
 
     def test_recognizes_all_standard_indexes(self):
         score = CheesecakeScore(cheesecake_run_output)
         check_subindices(score.documentation, sub_scores_documentation)
         check_subindices(score.code_kwalitee, sub_scores_code_kwalitee)
 
-class TestCheesecakeScore(TestCaseWithSpec):
-    context = "Class CheesecakeScore"
+class TestCheesecakeScore(unittest.TestCase):
+    "Class CheesecakeScore"
 
     def test_can_serialize_itself(self):
         MainIndex = CheesecakeScore.MainIndex
 
         assert serialized == expected
 
-class TestReadCheesecakeRuns(TestCaseWithSpec):
-    context = "Method Store._read_cheesecake_runs()"
+class TestReadCheesecakeRuns(unittest.TestCase):
+    "Method Store._read_cheesecake_runs()"
 
     def setUp(self):
         self.original_os_listdir = os.listdir
 
         check_calls(store_mock, [('save_run', check_run)])
 
-class TestRunsCount(TestCaseWithSpec):
-    context = "Method Store._get_runs_count()"
+class TestRunsCount(unittest.TestCase):
+    "Method Store._get_runs_count()"
 
     def setUp(self):
         self.original_os_listdir = os.listdir
 
         self.assertEqual(self.store_mock._get_runs_count(), 102)
 
-class TestGetFailures(TestCaseWithSpec):
-    context = "Method Store._get_failures()"
+class TestGetFailures(unittest.TestCase):
+    "Method Store._get_failures()"
 
     def setUp(self):
         self.original_os_listdir = os.listdir
                          set(['2-PIL==1.1.5-failure-42.log',
                               '3-PIL==1.1.5-failure-42.log']))
 
-class TestReleasesToScore(TestCaseWithSpec):
-    context = "Attribute Store.releases_to_score"
+class TestReleasesToScore(unittest.TestCase):
+    "Attribute Store.releases_to_score"
 
     def test_is_empty_when_database_table_is_empty(self):
         store_mock = make_store_mock(cursor={'fetchall': []})
         self.assertEqual(store_mock.releases_to_score, list_of_releases)
 
 
-class TestSaveScore(TestCaseWithSpec):
-    context = "Method Store.save_score()"
+class TestSaveScore(unittest.TestCase):
+    "Method Store.save_score()"
 
     def test_saves_main_indexes_with_all_subindexes(self):
         store_mock = make_store_mock({'_save_main_index': ReturnValues(1,2,3),
             # Should use _add_score to keep Store up-to-date.
             ('_add_score', args_are('Durus', '3.4.1', durus_score))])
 
-class TestNumberOfFailures(TestCaseWithSpec):
-    context = "Method Store.number_of_failures()"
+class TestNumberOfFailures(unittest.TestCase):
+    "Method Store.number_of_failures()"
 
     def setUp(self):
         runs_list = [

tests/test_webui.py

-from _test_case_with_spec import TestCaseWithSpec
 import _path_setup
 
 from webui import put_anchors
 
 
-class TestMethodPutAnchors(TestCaseWithSpec):
-    context = "Method put_anchors()"
+class TestMethodPutAnchors:
+    "Method put_anchors()"
 
     def test_doesnt_insert_any_anchor_for_empty_log(self):
         assert '' == put_anchors('')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.