Style fixes and docstrings for tests

Dmitri Bogomolov 5 years ago
parent a3300ba8f1
commit d8b4682ee9
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13

@ -1,7 +1,12 @@
#!/usr/bin/env python
Utility configured as apinotifypath in bitmessagesettings
when pybitmessage started in test mode.
import sys
import tempfile
from test_process import put_signal_file

@ -1,3 +1,7 @@
Tests for core.
import unittest
@ -8,5 +12,6 @@ class TestCore(unittest.TestCase):
def run():
"""Starts all tests defined in this module"""
suite = unittest.TestLoader().loadTestsFromTestCase(TestCore)
return unittest.TextTestRunner(verbosity=2).run(suite)

@ -1,12 +1,17 @@
import xmlrpclib
Tests using API.
import base64
import json
import xmlrpclib
from time import sleep
from test_process import TestProcessProto
class TestAPI(TestProcessProto):
"""A test case for API"""
_process_cmd = ['pybitmessage', '-t']
_seed = base64.encodestring(
'TIGER, tiger, burning bright. In the forests of the night'
@ -14,11 +19,12 @@ class TestAPI(TestProcessProto):
def setUpClass(cls):
"""Setup XMLRPC proxy for pybitmessage API"""
super(TestAPI, cls).setUpClass()
cls.addresses = []
cls.api = xmlrpclib.ServerProxy(
for tick in range(0, 5):
for _ in range(0, 5):
if cls._get_readline('.api_started'):
print('API start detected!')

@ -1,19 +1,27 @@
import unittest
import subprocess
Common reusable code for tests and tests for pybitmessage process.
import os
import signal
import subprocess
import tempfile
import time
import unittest
import psutil
def put_signal_file(path, filename):
"""Creates file, presence of which is a signal about some event."""
with open(os.path.join(path, filename), 'wb') as outfile:
class TestProcessProto(unittest.TestCase):
"""Test case implementing common logic for external testing:
it starts pybitmessage in setUpClass() and stops it in tearDownClass()
_process_cmd = ['pybitmessage', '-d']
_threads_count = 14
_files = (
@ -23,6 +31,7 @@ class TestProcessProto(unittest.TestCase):
def setUpClass(cls):
"""Setup environment and start pybitmessage"""
cls.home = os.environ['BITMESSAGE_HOME'] = tempfile.gettempdir()
put_signal_file(cls.home, 'unittest.lock')
@ -48,6 +57,7 @@ class TestProcessProto(unittest.TestCase):
def tearDownClass(cls):
"""Ensures that pybitmessage stopped and removes files"""
@ -80,6 +90,7 @@ class TestProcessProto(unittest.TestCase):
class TestProcess(TestProcessProto):
"""A test case for pybitmessage process"""
def test_process_name(self):
"""Check PyBitmessage process name"""
self.assertEqual(, 'PyBitmessage')