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:
parent
e05c72ad8c
commit
ee2671a5f3
@ -147,6 +147,8 @@ def GetTestGroups():
|
|||||||
|
|
||||||
|
|
||||||
class TestApp(TestAppBase):
|
class TestApp(TestAppBase):
|
||||||
|
__test__ = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
def link_gui(gui):
|
def link_gui(gui):
|
||||||
gui.view = self.make_logger()
|
gui.view = self.make_logger()
|
||||||
|
@ -8,7 +8,13 @@
|
|||||||
|
|
||||||
import pytest
|
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 ..path import Path
|
||||||
from ..testutil import eq_
|
from ..testutil import eq_
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ class HelloRepeater(Repeater):
|
|||||||
|
|
||||||
def create_pair():
|
def create_pair():
|
||||||
b = Broadcaster()
|
b = Broadcaster()
|
||||||
l = HelloListener(b)
|
listener = HelloListener(b)
|
||||||
return b, l
|
return b, listener
|
||||||
|
|
||||||
|
|
||||||
def test_disconnect_during_notification():
|
def test_disconnect_during_notification():
|
||||||
@ -60,53 +60,53 @@ def test_disconnect_during_notification():
|
|||||||
|
|
||||||
def test_disconnect():
|
def test_disconnect():
|
||||||
# After a disconnect, the listener doesn't hear anything.
|
# After a disconnect, the listener doesn't hear anything.
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
l.connect()
|
listener.connect()
|
||||||
l.disconnect()
|
listener.disconnect()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
eq_(l.hello_count, 0)
|
eq_(listener.hello_count, 0)
|
||||||
|
|
||||||
|
|
||||||
def test_disconnect_when_not_connected():
|
def test_disconnect_when_not_connected():
|
||||||
# When disconnecting an already disconnected listener, nothing happens.
|
# When disconnecting an already disconnected listener, nothing happens.
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
l.disconnect()
|
listener.disconnect()
|
||||||
|
|
||||||
|
|
||||||
def test_not_connected_on_init():
|
def test_not_connected_on_init():
|
||||||
# A listener is not initialized connected.
|
# A listener is not initialized connected.
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
eq_(l.hello_count, 0)
|
eq_(listener.hello_count, 0)
|
||||||
|
|
||||||
|
|
||||||
def test_notify():
|
def test_notify():
|
||||||
# The listener listens to the broadcaster.
|
# The listener listens to the broadcaster.
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
eq_(l.hello_count, 1)
|
eq_(listener.hello_count, 1)
|
||||||
|
|
||||||
|
|
||||||
def test_reconnect():
|
def test_reconnect():
|
||||||
# It's possible to reconnect a listener after disconnection.
|
# It's possible to reconnect a listener after disconnection.
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
l.connect()
|
listener.connect()
|
||||||
l.disconnect()
|
listener.disconnect()
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
eq_(l.hello_count, 1)
|
eq_(listener.hello_count, 1)
|
||||||
|
|
||||||
|
|
||||||
def test_repeater():
|
def test_repeater():
|
||||||
b = Broadcaster()
|
b = Broadcaster()
|
||||||
r = HelloRepeater(b)
|
r = HelloRepeater(b)
|
||||||
l = HelloListener(r)
|
listener = HelloListener(r)
|
||||||
r.connect()
|
r.connect()
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
eq_(r.hello_count, 1)
|
eq_(r.hello_count, 1)
|
||||||
eq_(l.hello_count, 1)
|
eq_(listener.hello_count, 1)
|
||||||
|
|
||||||
|
|
||||||
def test_repeater_with_repeated_notifications():
|
def test_repeater_with_repeated_notifications():
|
||||||
@ -124,15 +124,15 @@ def test_repeater_with_repeated_notifications():
|
|||||||
|
|
||||||
b = Broadcaster()
|
b = Broadcaster()
|
||||||
r = MyRepeater(b)
|
r = MyRepeater(b)
|
||||||
l = HelloListener(r)
|
listener = HelloListener(r)
|
||||||
r.connect()
|
r.connect()
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("hello")
|
b.notify("hello")
|
||||||
b.notify(
|
b.notify(
|
||||||
"foo"
|
"foo"
|
||||||
) # if the repeater repeated this notif, we'd get a crash on HelloListener
|
) # if the repeater repeated this notif, we'd get a crash on HelloListener
|
||||||
eq_(r.hello_count, 1)
|
eq_(r.hello_count, 1)
|
||||||
eq_(l.hello_count, 1)
|
eq_(listener.hello_count, 1)
|
||||||
eq_(r.foo_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.
|
# if a repeater doesn't handle a particular message, it doesn't crash and simply repeats it.
|
||||||
b = Broadcaster()
|
b = Broadcaster()
|
||||||
r = Repeater(b) # doesnt handle hello
|
r = Repeater(b) # doesnt handle hello
|
||||||
l = HelloListener(r)
|
listener = HelloListener(r)
|
||||||
r.connect()
|
r.connect()
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("hello") # no crash
|
b.notify("hello") # no crash
|
||||||
eq_(l.hello_count, 1)
|
eq_(listener.hello_count, 1)
|
||||||
|
|
||||||
|
|
||||||
def test_bind_messages():
|
def test_bind_messages():
|
||||||
b, l = create_pair()
|
b, listener = create_pair()
|
||||||
l.bind_messages({"foo", "bar"}, l.hello)
|
listener.bind_messages({"foo", "bar"}, listener.hello)
|
||||||
l.connect()
|
listener.connect()
|
||||||
b.notify("foo")
|
b.notify("foo")
|
||||||
b.notify("bar")
|
b.notify("bar")
|
||||||
b.notify("hello") # Normal dispatching still work
|
b.notify("hello") # Normal dispatching still work
|
||||||
eq_(l.hello_count, 3)
|
eq_(listener.hello_count, 3)
|
||||||
|
@ -51,7 +51,7 @@ def test_init_with_tuple_and_list(force_ossep):
|
|||||||
|
|
||||||
def test_init_with_invalid_value(force_ossep):
|
def test_init_with_invalid_value(force_ossep):
|
||||||
try:
|
try:
|
||||||
path = Path(42)
|
path = Path(42) # noqa: F841
|
||||||
assert False
|
assert False
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
@ -143,8 +143,8 @@ def test_path_slice(force_ossep):
|
|||||||
eq_((), foobar[:foobar])
|
eq_((), foobar[:foobar])
|
||||||
abcd = Path("a/b/c/d")
|
abcd = Path("a/b/c/d")
|
||||||
a = Path("a")
|
a = Path("a")
|
||||||
b = Path("b")
|
b = Path("b") # noqa: #F841
|
||||||
c = Path("c")
|
c = Path("c") # noqa: #F841
|
||||||
d = Path("d")
|
d = Path("d")
|
||||||
z = Path("z")
|
z = Path("z")
|
||||||
eq_("b/c", abcd[a:d])
|
eq_("b/c", abcd[a:d])
|
||||||
|
@ -11,6 +11,8 @@ from ..gui.table import Table, GUITable, Row
|
|||||||
|
|
||||||
|
|
||||||
class TestRow(Row):
|
class TestRow(Row):
|
||||||
|
__test__ = False
|
||||||
|
|
||||||
def __init__(self, table, index, is_new=False):
|
def __init__(self, table, index, is_new=False):
|
||||||
Row.__init__(self, table)
|
Row.__init__(self, table)
|
||||||
self.is_new = is_new
|
self.is_new = is_new
|
||||||
@ -28,6 +30,8 @@ class TestRow(Row):
|
|||||||
|
|
||||||
|
|
||||||
class TestGUITable(GUITable):
|
class TestGUITable(GUITable):
|
||||||
|
__test__ = False
|
||||||
|
|
||||||
def __init__(self, rowcount, viewclass=CallLogger):
|
def __init__(self, rowcount, viewclass=CallLogger):
|
||||||
GUITable.__init__(self)
|
GUITable.__init__(self)
|
||||||
self.view = viewclass()
|
self.view = viewclass()
|
||||||
|
@ -12,7 +12,31 @@ from pytest import raises
|
|||||||
|
|
||||||
from ..testutil import eq_
|
from ..testutil import eq_
|
||||||
from ..path import Path
|
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():
|
def test_nonone():
|
||||||
|
2
run.py
2
run.py
@ -16,7 +16,7 @@ from PyQt5.QtWidgets import QApplication
|
|||||||
from hscommon.trans import install_gettext_trans_under_qt
|
from hscommon.trans import install_gettext_trans_under_qt
|
||||||
from qtlib.error_report_dialog import install_excepthook
|
from qtlib.error_report_dialog import install_excepthook
|
||||||
from qtlib.util import setupQtLogging
|
from qtlib.util import setupQtLogging
|
||||||
from qt import dg_rc
|
from qt import dg_rc # noqa: F401
|
||||||
from qt.platform import BASE_PATH
|
from qt.platform import BASE_PATH
|
||||||
from core import __version__, __appname__
|
from core import __version__, __appname__
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -31,7 +31,7 @@ commands =
|
|||||||
python package.py
|
python package.py
|
||||||
|
|
||||||
[flake8]
|
[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
|
max-line-length = 120
|
||||||
ignore = E731,E203,E501,W503
|
ignore = E731,E203,E501,W503
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user