Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kura committed Sep 27, 2013
1 parent 0388496 commit be35072
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[bumpversion]
current_version = 1.8.0
files = blackhole/__init__.py
commit = True
tag = True

tag_name = {current_version}
10 changes: 0 additions & 10 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import unittest
import sys


class BaseTest(unittest.TestCase):

def __init__(self):
sys.argv = []
super(BaseTest, self).__init__()
32 changes: 15 additions & 17 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
from blackhole.application import (set_action, set_options, fork, daemon)
from blackhole import opts

from .tests import BaseTest


class TestSetActionStart(BaseTest):
class TestSetActionStart(unittest.TestCase):

def setUp(self):
sys.argv = ['blackhole_unused', 'start']
Expand All @@ -48,7 +46,7 @@ def test_set_action_start(self):
self.assertEquals(set_action(), 'start')


class TestSetActionStop(BaseTest):
class TestSetActionStop(unittest.TestCase):

def setUp(self):
sys.argv = ['blackhole_unused', 'stop']
Expand All @@ -57,7 +55,7 @@ def test_set_action_stop(self):
self.assertEquals(set_action(), 'stop')


class TestSetActionStatus(BaseTest):
class TestSetActionStatus(unittest.TestCase):

def setUp(self):
sys.argv = ['blackhole_unused', 'status']
Expand All @@ -66,7 +64,7 @@ def test_set_action_status(self):
self.assertEquals(set_action(), 'status')


class TestSetOptions(BaseTest):
class TestSetOptions(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -78,7 +76,7 @@ def test_set_options(self):
self.assertEquals(True, True)


class TestSetOptionsSSLNoCertNoKey(BaseTest):
class TestSetOptionsSSLNoCertNoKey(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -93,7 +91,7 @@ def test_set_options_ssl_no_cert_no_key(self, exit_mock):
self.assertTrue(exit_mock.called)


class TestSetOptionsSSLCertNoKey(BaseTest):
class TestSetOptionsSSLCertNoKey(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -109,7 +107,7 @@ def test_set_options_ssl_cert_no_key(self, exit_mock):
self.assertTrue(exit_mock.called)


class TestSetOptionsSSLKeyNoCert(BaseTest):
class TestSetOptionsSSLKeyNoCert(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -125,7 +123,7 @@ def test_set_options_ssl_key_no_cert(self, exit_mock):
self.assertTrue(exit_mock.called)


class TestSetOptionsSSLCertAndKey(BaseTest):
class TestSetOptionsSSLCertAndKey(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -142,7 +140,7 @@ def test_set_options_ssl_cert_and_key(self, exit_mock):
self.assertFalse(exit_mock.called)


class TestSetOptionsDebug(BaseTest):
class TestSetOptionsDebug(unittest.TestCase):

def setUp(self):
options.delay = 0
Expand All @@ -157,7 +155,7 @@ def test_set_options_debug(self, stdout_mock):
self.assertEquals(stdout_mock.getvalue(), val)


class TestSetOptionsDelay(BaseTest):
class TestSetOptionsDelay(unittest.TestCase):

def setUp(self):
options.debug = False
Expand All @@ -173,7 +171,7 @@ def test_set_options_delay(self, stdout_mock):
self.assertEquals(stdout_mock.getvalue(), val)


class TestDaemonStop(BaseTest):
class TestDaemonStop(unittest.TestCase):

def setUp(self):
sys.argv = ('blackhole', 'stop')
Expand All @@ -186,7 +184,7 @@ def test_daemon_stop(self, exit_mock, daemon_mock):
self.assertTrue(exit_mock.called)


class TestDaemonStatus(BaseTest):
class TestDaemonStatus(unittest.TestCase):

def setUp(self):
sys.argv = ('blackhole', 'status')
Expand All @@ -199,7 +197,7 @@ def test_daemon_status(self, exit_mock, daemon_mock):
self.assertTrue(exit_mock.called)


class TestDaemonStart(BaseTest):
class TestDaemonStart(unittest.TestCase):

def setUp(self):
sys.argv = ('blackhole', 'start')
Expand All @@ -211,15 +209,15 @@ def test_daemon_start(self, daemon_mock):
self.assertTrue(isinstance(d, Deiman))


class TestDaemonInvalidAction(BaseTest):
class TestDaemonInvalidAction(unittest.TestCase):

@patch('sys.exit')
def test_daemon_invalid_action(self, exit_mock):
daemon('kurakurakura')
self.assertTrue(exit_mock.called)


class TestFork(BaseTest):
class TestFork(unittest.TestCase):

@patch('blackhole.utils.set_process_title')
@patch('tornado.process.fork_processes')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_deprecated_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from blackhole import opts


class TestDeprecatedOpts(BaseTest):
class TestDeprecatedOpts(unittest.TestCase):

def setUp(self):
options.ssl_ca_certs_dir = "/dev/null"
Expand Down

0 comments on commit be35072

Please sign in to comment.