diff --git a/tests/test_languages.py b/tests/test_languages.py index 211bd7c..e7a1cc9 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -6,6 +6,8 @@ from wakatime.packages import requests import time from wakatime.compat import u +from wakatime.exceptions import NotYetImplemented +from wakatime.languages import TokenParser from wakatime.packages.requests.models import Response from . import utils @@ -20,6 +22,16 @@ class LanguagesTestCase(utils.TestCase): ['wakatime.session_cache.SessionCache.get', requests.session], ] + def test_token_parser(self): + with utils.mock.patch('wakatime.languages.TokenParser._extract_tokens') as mock_extract_tokens: + + with self.assertRaises(NotYetImplemented): + source_file = 'tests/samples/codefiles/see.h' + parser = TokenParser(source_file) + parser.parse() + + mock_extract_tokens.assert_called_once_with() + def test_language_detected_for_header_file(self): response = Response() response.status_code = 500 diff --git a/wakatime/exceptions.py b/wakatime/exceptions.py new file mode 100644 index 0000000..e99ba90 --- /dev/null +++ b/wakatime/exceptions.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +""" + wakatime.exceptions + ~~~~~~~~~~~~~~~~~~~ + + Custom exceptions. + + :copyright: (c) 2015 Alan Hamlett. + :license: BSD, see LICENSE for more details. +""" + + +class NotYetImplemented(Exception): + """This method needs to be implemented.""" diff --git a/wakatime/languages/__init__.py b/wakatime/languages/__init__.py index 130d947..5cbe9f5 100644 --- a/wakatime/languages/__init__.py +++ b/wakatime/languages/__init__.py @@ -15,6 +15,7 @@ import sys import traceback from ..compat import u, open, import_module +from ..exceptions import NotYetImplemented log = logging.getLogger('WakaTime') @@ -39,7 +40,7 @@ class TokenParser(object): """ if not tokens and not self.tokens: self.tokens = self._extract_tokens() - raise Exception('Not yet implemented.') + raise NotYetImplemented() def append(self, dep, truncate=False, separator=None, truncate_to=None, strip_whitespace=True):