Private GIT

Skip to content
Snippets Groups Projects
Commit 5b48eeac authored by labrys's avatar labrys
Browse files

Merge pull request #241 from labrys/lint-issue_submitter_tests

Lint 10/10
parents 766ddcba 87e0e6e2
Branches
Tags
No related merge requests found
...@@ -17,29 +17,42 @@ ...@@ -17,29 +17,42 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickRage. If not, see <http://www.gnu.org/licenses/>. # along with SickRage. If not, see <http://www.gnu.org/licenses/>.
"""
Test exception logging
"""
import sys, os.path import sys
import os.path
import unittest
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib'))) sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib')))
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import unittest
from sickbeard import logger from sickbeard import logger
from sickrage.helper.exceptions import ex from sickrage.helper.exceptions import ex
def error():
def exception_generator():
"""
Dummy function to raise a fake exception and log it
"""
try: try:
raise Exception('FAKE EXCEPTION') raise Exception('FAKE EXCEPTION')
except Exception as e: except Exception as error:
logger.log(u"FAKE ERROR: " + ex(e), logger.ERROR) logger.log(u"FAKE ERROR: " + ex(error), logger.ERROR) # pylint: disable=no-member
logger.submit_errors() logger.submit_errors() # pylint: disable=no-member
raise raise
class IssueSubmitterBasicTests(unittest.TestCase): class IssueSubmitterBasicTests(unittest.TestCase):
"""
Tests logging of exceptions
"""
def test_submitter(self): def test_submitter(self):
self.assertRaises(Exception, error) """
Test that an exception is raised
"""
self.assertRaises(Exception, exception_generator)
if __name__ == "__main__": if __name__ == "__main__":
...@@ -47,5 +60,6 @@ if __name__ == "__main__": ...@@ -47,5 +60,6 @@ if __name__ == "__main__":
print "STARTING - ISSUE SUBMITTER TESTS" print "STARTING - ISSUE SUBMITTER TESTS"
print "==================" print "=================="
print "######################################################################" print "######################################################################"
suite = unittest.TestLoader().loadTestsFromTestCase(IssueSubmitterBasicTests)
unittest.TextTestRunner(verbosity=2).run(suite) SUITE = unittest.TestLoader().loadTestsFromTestCase(IssueSubmitterBasicTests)
unittest.TextTestRunner(verbosity=2).run(SUITE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment