Skip to content

Commit af4bfbf

Browse files
committed
Code quality
- refactoring - autodetect Qt tests - remove obsolete code
1 parent dcbcc4a commit af4bfbf

9 files changed

Lines changed: 20 additions & 119 deletions

File tree

src/bitmessageqt/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from bmconfigparser import config
3434
import namecoin
3535
from messageview import MessageView
36-
from migrationwizard import Ui_MigrationWizard
3736
from foldertree import (
3837
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
3938
MessageList_AddressWidget, MessageList_SubjectWidget,
@@ -4296,15 +4295,17 @@ def __init__(self, *argv):
42964295
# for whenever a second instance tries to run focus the application.
42974296
self.server = QLocalServer()
42984297
self.server.listen(self.UUID)
4299-
self.server.newConnection.connect(self.on_new_connection)
4298+
self.server.newConnection.connect(
4299+
BitmessageQtApplication.on_new_connection)
43004300

43014301
self.setStyleSheet("QStatusBar::item { border: 0px solid black }")
43024302

43034303
def __del__(self):
43044304
if self.server:
43054305
self.server.close()
43064306

4307-
def on_new_connection(self): # pylint: disable=no-self-use
4307+
@staticmethod
4308+
def on_new_connection():
43084309
if myapp:
43094310
myapp.appIndicatorShow()
43104311

src/bitmessageqt/migrationwizard.py

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/bitmessageqt/networkstatus.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def stopUpdate(self):
5757
"""Stop counter update timer"""
5858
self.timer.stop()
5959

60-
def formatBytes(self, num):
60+
@staticmethod
61+
def formatBytes(num):
6162
"""Format bytes nicely (SI prefixes)"""
62-
# pylint: disable=no-self-use
6363
for x in [
6464
_translate(
6565
"networkstatus",
@@ -76,9 +76,9 @@ def formatBytes(self, num):
7676
num /= 1000.0
7777
return "%3.0f %s" % (num, 'TB')
7878

79-
def formatByteRate(self, num):
79+
@staticmethod
80+
def formatByteRate(num):
8081
"""Format transfer speed in kB/s"""
81-
# pylint: disable=no-self-use
8282
num /= 1000
8383
return "%4.0f kB" % num
8484

@@ -135,13 +135,13 @@ def updateNumberOfBytes(self):
135135
_translate(
136136
"networkstatus",
137137
"Down: %1/s Total: %2").arg(
138-
self.formatByteRate(network.stats.downloadSpeed()),
139-
self.formatBytes(network.stats.receivedBytes())))
138+
NetworkStatus.formatByteRate(network.stats.downloadSpeed()),
139+
NetworkStatus.formatBytes(network.stats.receivedBytes())))
140140
self.labelBytesSentCount.setText(
141141
_translate(
142142
"networkstatus", "Up: %1/s Total: %2").arg(
143-
self.formatByteRate(network.stats.uploadSpeed()),
144-
self.formatBytes(network.stats.sentBytes())))
143+
NetworkStatus.formatByteRate(network.stats.uploadSpeed()),
144+
NetworkStatus.formatBytes(network.stats.sentBytes())))
145145

146146
def updateNetworkStatusTab(self, outbound, add, destination):
147147
"""Add or remove an entry to the list of connected peers"""

src/bitmessageqt/tests/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
11
"""bitmessageqt tests"""
2-
3-
from .addressbook import TestAddressbook
4-
from .main import TestMain, TestUISignaler
5-
from .settings import TestSettings
6-
from .support import TestSupport
7-
from .test_import import TestImports
8-
from .test_startup import TestStartup
9-
from .test_widgets import (
10-
TestAddressValidator, TestLanguageBox, TestMessageView,
11-
TestSafeHTMLParser
12-
)
13-
14-
__all__ = [
15-
"TestAddressbook", "TestAddressValidator", "TestLanguageBox",
16-
"TestImports", "TestMain", "TestMessageView", "TestSafeHTMLParser",
17-
"TestSettings", "TestStartup", "TestSupport", "TestUISignaler"
18-
]

src/bitmessageqt/tests/addressbook.py renamed to src/bitmessageqt/tests/test_addressbook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import helper_addressbook
55
from bitmessageqt.support import createAddressIfNeeded
66

7-
from main import TestBase # pylint: disable=no-name-in-module
7+
from .test_main import TestBase
88

99

1010
class TestAddressbook(TestBase):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from bmconfigparser import config
99
from bitmessageqt import settings
1010

11-
from .main import TestBase
11+
from .test_main import TestBase
1212

1313

1414
class TestSettings(TestBase):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sys
77

8-
from main import TestBase # pylint: disable=no-name-in-module
8+
from .test_main import TestBase
99
from shared import isAddressInMyAddressBook
1010

1111

src/tests/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ def run():
422422
except ImportError:
423423
Xvfb = None
424424
else:
425-
qt_tests = loader.loadTestsFromModule(bitmessageqt.tests)
425+
qt_test_dir = os.path.dirname(bitmessageqt.tests.__file__)
426+
qt_tests = loader.discover(
427+
qt_test_dir,
428+
top_level_dir=os.path.dirname(
429+
os.path.dirname(qt_test_dir)))
426430
suite.addTests(qt_tests)
427431

428432
def keep_exc(ex_cls, exc, tb): # pylint: disable=unused-argument

0 commit comments

Comments
 (0)