first tests, and disable logging while testing
This commit is contained in:
parent
fb97fafb37
commit
4a5e2d9328
5 changed files with 36 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
[run]
|
||||
branch = false
|
||||
omit = wakatime/packages/*
|
||||
omit =
|
||||
wakatime/packages/*
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
coverage==3.7.1
|
||||
mock==1.3.0
|
||||
nose==1.3.7
|
||||
nose-exclude==0.3.0
|
||||
|
|
0
tests/samples/emptyfile.txt
Normal file
0
tests/samples/emptyfile.txt
Normal file
31
tests/test_wakatime_base.py
Normal file
31
tests/test_wakatime_base.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import logging
|
||||
import unittest
|
||||
|
||||
try:
|
||||
from mock import patch
|
||||
except:
|
||||
from unittest.mock import patch
|
||||
|
||||
from wakatime.base import main
|
||||
|
||||
|
||||
@patch('requests.post')
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
# disable logging while testing
|
||||
logging.disable(logging.CRITICAL)
|
||||
|
||||
def test_help_contents(self, mock_post):
|
||||
with self.assertRaises(SystemExit):
|
||||
args = ['', '--help']
|
||||
retval = main(args)
|
||||
self.assertEquals(retval, 0)
|
||||
|
||||
def test_argument_parsing(self, mock_post):
|
||||
args = ['', '--file', 'tests/samples/emptyfile.txt']
|
||||
retval = main(args)
|
||||
self.assertEquals(retval, 0)
|
|
@ -22,7 +22,7 @@ import traceback
|
|||
import socket
|
||||
try:
|
||||
import ConfigParser as configparser
|
||||
except ImportError:
|
||||
except ImportError: # pragma: nocover
|
||||
import configparser
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
@ -40,7 +40,7 @@ from .session_cache import SessionCache
|
|||
from .stats import get_file_stats
|
||||
try:
|
||||
from .packages import tzlocal
|
||||
except:
|
||||
except: # pragma: nocover
|
||||
from .packages import tzlocal3 as tzlocal
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue