1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-11-19 05:19:03 +00:00

More Test and Flake8 Cleanup

- Allow flake8 to check more files as well.
This commit is contained in:
Andrew Senetar 2020-06-27 01:08:12 -05:00
parent e05c72ad8c
commit ee2671a5f3
Signed by: arsenetar
GPG Key ID: C63300DCE48AB2F1
8 changed files with 74 additions and 38 deletions

View File

@ -147,6 +147,8 @@ def GetTestGroups():
class TestApp(TestAppBase):
__test__ = False
def __init__(self):
def link_gui(gui):
gui.view = self.make_logger()

View File

@ -8,7 +8,13 @@
import pytest
from ..conflict import *
from ..conflict import (
get_conflicted_name,
get_unconflicted_name,
is_conflicted,
smart_copy,
smart_move,
)
from ..path import Path
from ..testutil import eq_

View File

@ -28,8 +28,8 @@ class HelloRepeater(Repeater):
def create_pair():
b = Broadcaster()
l = HelloListener(b)
return b, l
listener = HelloListener(b)
return b, listener
def test_disconnect_during_notification():
@ -60,53 +60,53 @@ def test_disconnect_during_notification():
def test_disconnect():
# After a disconnect, the listener doesn't hear anything.
b, l = create_pair()
l.connect()
l.disconnect()
b, listener = create_pair()
listener.connect()
listener.disconnect()
b.notify("hello")
eq_(l.hello_count, 0)
eq_(listener.hello_count, 0)
def test_disconnect_when_not_connected():
# When disconnecting an already disconnected listener, nothing happens.
b, l = create_pair()
l.disconnect()
b, listener = create_pair()
listener.disconnect()
def test_not_connected_on_init():
# A listener is not initialized connected.
b, l = create_pair()
b, listener = create_pair()
b.notify("hello")
eq_(l.hello_count, 0)
eq_(listener.hello_count, 0)
def test_notify():
# The listener listens to the broadcaster.
b, l = create_pair()
l.connect()
b, listener = create_pair()
listener.connect()
b.notify("hello")
eq_(l.hello_count, 1)
eq_(listener.hello_count, 1)
def test_reconnect():
# It's possible to reconnect a listener after disconnection.
b, l = create_pair()
l.connect()
l.disconnect()
l.connect()
b, listener = create_pair()
listener.connect()
listener.disconnect()
listener.connect()
b.notify("hello")
eq_(l.hello_count, 1)
eq_(listener.hello_count, 1)
def test_repeater():
b = Broadcaster()
r = HelloRepeater(b)
l = HelloListener(r)
listener = HelloListener(r)
r.connect()
l.connect()
listener.connect()
b.notify("hello")
eq_(r.hello_count, 1)
eq_(l.hello_count, 1)
eq_(listener.hello_count, 1)
def test_repeater_with_repeated_notifications():
@ -124,15 +124,15 @@ def test_repeater_with_repeated_notifications():
b = Broadcaster()
r = MyRepeater(b)
l = HelloListener(r)
listener = HelloListener(r)
r.connect()
l.connect()
listener.connect()
b.notify("hello")
b.notify(
"foo"
) # if the repeater repeated this notif, we'd get a crash on HelloListener
eq_(r.hello_count, 1)
eq_(l.hello_count, 1)
eq_(listener.hello_count, 1)
eq_(r.foo_count, 1)
@ -140,18 +140,18 @@ def test_repeater_doesnt_try_to_dispatch_to_self_if_it_cant():
# if a repeater doesn't handle a particular message, it doesn't crash and simply repeats it.
b = Broadcaster()
r = Repeater(b) # doesnt handle hello
l = HelloListener(r)
listener = HelloListener(r)
r.connect()
l.connect()
listener.connect()
b.notify("hello") # no crash
eq_(l.hello_count, 1)
eq_(listener.hello_count, 1)
def test_bind_messages():
b, l = create_pair()
l.bind_messages({"foo", "bar"}, l.hello)
l.connect()
b, listener = create_pair()
listener.bind_messages({"foo", "bar"}, listener.hello)
listener.connect()
b.notify("foo")
b.notify("bar")
b.notify("hello") # Normal dispatching still work
eq_(l.hello_count, 3)
eq_(listener.hello_count, 3)

View File

@ -51,7 +51,7 @@ def test_init_with_tuple_and_list(force_ossep):
def test_init_with_invalid_value(force_ossep):
try:
path = Path(42)
path = Path(42) # noqa: F841
assert False
except TypeError:
pass
@ -143,8 +143,8 @@ def test_path_slice(force_ossep):
eq_((), foobar[:foobar])
abcd = Path("a/b/c/d")
a = Path("a")
b = Path("b")
c = Path("c")
b = Path("b") # noqa: #F841
c = Path("c") # noqa: #F841
d = Path("d")
z = Path("z")
eq_("b/c", abcd[a:d])

View File

@ -11,6 +11,8 @@ from ..gui.table import Table, GUITable, Row
class TestRow(Row):
__test__ = False
def __init__(self, table, index, is_new=False):
Row.__init__(self, table)
self.is_new = is_new
@ -28,6 +30,8 @@ class TestRow(Row):
class TestGUITable(GUITable):
__test__ = False
def __init__(self, rowcount, viewclass=CallLogger):
GUITable.__init__(self)
self.view = viewclass()

View File

@ -12,7 +12,31 @@ from pytest import raises
from ..testutil import eq_
from ..path import Path
from ..util import *
from ..util import (
nonone,
tryint,
minmax,
first,
flatten,
dedupe,
stripfalse,
extract,
allsame,
trailiter,
format_time,
format_time_decimal,
format_size,
remove_invalid_xml,
multi_replace,
delete_if_empty,
open_if_filename,
FileOrPath,
iterconsume,
escape,
get_file_ext,
rem_file_ext,
pluralize,
)
def test_nonone():

2
run.py
View File

@ -16,7 +16,7 @@ from PyQt5.QtWidgets import QApplication
from hscommon.trans import install_gettext_trans_under_qt
from qtlib.error_report_dialog import install_excepthook
from qtlib.util import setupQtLogging
from qt import dg_rc
from qt import dg_rc # noqa: F401
from qt.platform import BASE_PATH
from core import __version__, __appname__

View File

@ -31,7 +31,7 @@ commands =
python package.py
[flake8]
exclude = .tox,env,build,hscommon/tests,cocoalib,cocoa,help,./qt/dg_rc.py,qt/run_template.py,cocoa/run_template.py,./run.py,./pkg
exclude = .tox,env,build,cocoalib,cocoa,help,./qt/dg_rc.py,cocoa/run_template.py,./pkg
max-line-length = 120
ignore = E731,E203,E501,W503