1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

Replace all relative imports

This commit is contained in:
2022-05-09 01:40:08 -05:00
parent f7ed1c801c
commit e382683f66
79 changed files with 155 additions and 216 deletions

View File

@@ -8,28 +8,12 @@
import pytest
import threading
import py.path
def eq_(a, b, msg=None):
__tracebackhide__ = True
assert a == b, msg or "{!r} != {!r}".format(a, b)
def eq_sorted(a, b, msg=None):
"""If both a and b are iterable sort them and compare using eq_, otherwise just pass them through to eq_ anyway."""
try:
eq_(sorted(a), sorted(b), msg)
except TypeError:
eq_(a, b, msg)
def assert_almost_equal(a, b, places=7):
__tracebackhide__ = True
assert round(a, ndigits=places) == round(b, ndigits=places)
def callcounter():
def f(*args, **kwargs):
f.callcount += 1
@@ -38,23 +22,6 @@ def callcounter():
return f
class TestData:
def __init__(self, datadirpath):
self.datadirpath = py.path.local(datadirpath)
def filepath(self, relative_path, *args):
"""Returns the path of a file in testdata.
'relative_path' can be anything that can be added to a Path
if args is not empty, it will be joined to relative_path
"""
resultpath = self.datadirpath.join(relative_path)
if args:
resultpath = resultpath.join(*args)
assert resultpath.check()
return str(resultpath)
class CallLogger:
"""This is a dummy object that logs all calls made to it.
@@ -168,20 +135,6 @@ def app(request):
return app
def jointhreads():
"""Join all threads to the main thread"""
for thread in threading.enumerate():
if hasattr(thread, "BUGGY"):
continue
if thread.getName() != "MainThread" and thread.isAlive():
if hasattr(thread, "close"):
thread.close()
thread.join(1)
if thread.isAlive():
print("Thread problem. Some thread doesn't want to stop.")
thread.BUGGY = True
def _unify_args(func, args, kwargs, args_to_ignore=None):
"""Unify args and kwargs in the same dictionary.