Apply flake8 checks to tests

This commit is contained in:
Virgil Dupras 2016-05-29 15:02:39 -04:00
parent 9ed4b7abf0
commit 130581db53
13 changed files with 798 additions and 809 deletions

View File

@ -273,7 +273,6 @@ class TestCaseDupeGuruWithResults:
# When marking selected dupes with a heterogenous selection, mark all selected dupes. When
# it's homogenous, simply toggle.
app = self.app
objects = self.objects
self.rtable.select([1])
app.toggle_selected_mark_state()
# index 0 is unmarkable, but we throw it in the bunch to be sure that it doesn't make the
@ -400,8 +399,6 @@ class TestCaseDupeGuruWithResults:
def test_dont_crash_on_delta_powermarker_dupecount_sort(self, do_setup):
# Don't crash when sorting by dupe count or percentage while delta+powermarker are enabled.
# Ref #238
app = self.app
objects = self.objects
self.rtable.delta_values = True
self.rtable.power_marker = True
self.rtable.sort('dupe_count', False)

View File

@ -1,12 +1,10 @@
# Created By: Virgil Dupras
# Created On: 2011/09/07
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html
from hscommon.testutil import TestApp as TestAppBase, eq_, with_app
from hscommon.testutil import TestApp as TestAppBase, eq_, with_app # noqa
from hscommon.path import Path
from hscommon.util import get_file_ext, format_size
from hscommon.gui.column import Column
@ -15,9 +13,7 @@ from hscommon.jobprogress.job import nulljob, JobCancelled
from .. import engine
from .. import prioritize
from ..engine import getwords
from ..app import DupeGuru as DupeGuruBase, cmp_value
from ..gui.details_panel import DetailsPanel
from ..gui.directory_tree import DirectoryTree
from ..app import DupeGuru as DupeGuruBase
from ..gui.result_table import ResultTable as ResultTableBase
from ..gui.prioritize_dialog import PrioritizeDialog
@ -119,7 +115,13 @@ class NamedObject:
# "ibabtu" (1)
# "ibabtu" (1)
def GetTestGroups():
objects = [NamedObject("foo bar"),NamedObject("bar bleh"),NamedObject("foo bleh"),NamedObject("ibabtu"),NamedObject("ibabtu")]
objects = [
NamedObject("foo bar"),
NamedObject("bar bleh"),
NamedObject("foo bleh"),
NamedObject("ibabtu"),
NamedObject("ibabtu")
]
objects[1].size = 1024
matches = engine.getmatches(objects) #we should have 5 matches
groups = engine.get_groups(matches) #We should have 2 groups
@ -137,7 +139,6 @@ class TestApp(TestAppBase):
return gui
TestAppBase.__init__(self)
make_gui = self.make_gui
self.app = DupeGuru()
self.default_parent = self.app
self.rtable = link_gui(self.app.result_table)

View File

@ -1 +1 @@
from hscommon.testutil import pytest_funcarg__app
from hscommon.testutil import pytest_funcarg__app # noqa

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/02/27
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -15,7 +13,7 @@ from pytest import raises
from hscommon.path import Path
from hscommon.testutil import eq_
from ..directories import *
from ..directories import Directories, DirectoryState, AlreadyThereError, InvalidPathError
def create_fake_fs(rootpath):
# We have it as a separate function because other units are using it.
@ -44,6 +42,8 @@ def create_fake_fs(rootpath):
fp.close()
return rootpath
testpath = None
def setup_module(module):
# In this unit, we have tests depending on two directory structure. One with only one file in it
# and another with a more complex structure.

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/01/29
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -14,7 +12,11 @@ from hscommon.testutil import eq_, log_calls
from .base import NamedObject
from .. import engine
from ..engine import *
from ..engine import (
get_match, getwords, Group, getfields, unpack_fields, compare_fields, compare, WEIGHT_WORDS,
MATCH_SIMILAR_WORDS, NO_FIELD_ORDER, build_word_dict, get_groups, getmatches, Match,
getmatches_by_contents, merge_similar_words, reduce_common_words
)
no = NamedObject
@ -338,7 +340,8 @@ class TestCaseget_match:
assert object() not in m
def test_word_weight(self):
eq_(int((6.0 / 13.0) * 100),get_match(NamedObject("foo bar",True),NamedObject("bar bleh",True),(WEIGHT_WORDS,)).percentage)
m = get_match(NamedObject("foo bar", True), NamedObject("bar bleh", True), (WEIGHT_WORDS, ))
eq_(m.percentage, int((6.0 / 13.0) * 100))
class TestCaseGetMatches:

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/05/02
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -12,7 +10,7 @@ from xml.etree import ElementTree as ET
from pytest import raises
from hscommon.testutil import eq_
from ..ignore import *
from ..ignore import IgnoreList
def test_empty():
il = IgnoreList()

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/02/23
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -8,7 +6,7 @@
from hscommon.testutil import eq_
from ..markable import *
from ..markable import MarkableList, Markable
def gen():
ml = MarkableList()
@ -73,6 +71,7 @@ def test_change_notifications():
class Foobar(Markable):
def _did_mark(self, o):
self.log.append((True, o))
def _did_unmark(self, o):
self.log.append((False, o))

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/02/23
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at

View File

@ -471,9 +471,11 @@ def test_dont_group_files_that_dont_exist(tmpdir):
p['file1'].open('w').write('foo')
p['file2'].open('w').write('foo')
file1, file2 = fs.get_files(p)
def getmatches(*args, **kw):
file2.path.remove()
return [Match(file1, file2, 100)]
s._getmatches = getmatches
assert not s.get_dupe_groups([file1, file2])

View File

@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Created By: Virgil Dupras
# Created On: 2009-10-23
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -9,9 +6,8 @@
from hscommon.path import Path
from core.engine import getwords
from core.tests.scanner_test import NamedObject, no
from ..scanner import *
from core.tests.scanner_test import no
from ..scanner import ScannerME
def pytest_funcarg__fake_fileexists(request):
# This is a hack to avoid invalidating all previous tests since the scanner started to test

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/09/01
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
@ -11,7 +9,7 @@ from pytest import raises, skip
from hscommon.testutil import eq_
try:
from ..block import *
from ..block import avgdiff, getblocks2, NoBlocksError, DifferentBlockCountError
except ImportError:
skip("Can't import the block module, probably hasn't been compiled.")
@ -210,7 +208,6 @@ class TestCaseavgdiff:
my_avgdiff([], [])
def test_two_blocks(self):
im = empty()
b1 = (5, 10, 15)
b2 = (255, 250, 245)
b3 = (0, 0, 0)

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras
# Created On: 2006/09/14
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at

View File

@ -11,7 +11,7 @@ deps =
-r{toxinidir}/requirements-extra.txt
[flake8]
exclude = .tox,env,build,hscommon,qtlib,cocoalib,cocoa,help,./get-pip.py,./qt/dg_rc.py,./core*/tests,qt/run_template.py,cocoa/run_template.py,./run.py,./pkg
exclude = .tox,env,build,hscommon,qtlib,cocoalib,cocoa,help,./qt/dg_rc.py,qt/run_template.py,cocoa/run_template.py,./run.py,./pkg
max-line-length = 120
ignore = W391,W293,E302,E261,E226,E227,W291,E262,E303,E265,E731