Skip to content

Commit 26bbcf0

Browse files
committed
Removing all warnings during testing
1 parent d573e1a commit 26bbcf0

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
python-version: [3.5, 3.6, 3.7, 3.8]
16+
python-version: [ 3.6, 3.7, 3.8 ]
1717

1818
steps:
1919
- uses: actions/checkout@v2

reusables/cli.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,15 @@ def cat(file_path, encoding="utf-8", errors="strict"):
159159
/ \\
160160
| | _/
161161
| || | |
162-
\_||_/_/
162+
|_||_/_/
163163
164164
:param file_path: Path to file to read
165165
:param encoding: defaults to utf-8 to decode as, will fail on binary
166166
:param errors: Decoding errors: 'strict', 'ignore' or 'replace'
167167
"""
168168

169-
with open(file_path, "rb") as f:
170-
if python_version >= (2, 7):
171-
print(f.read().decode(encoding, errors=errors))
172-
else:
173-
print(f.read().decode(encoding))
169+
with open(file_path, "r", encoding=encoding, errors=errors) as f:
170+
print(f.read())
174171

175172

176173
def tail(file_path, lines=10, encoding="utf-8", printed=True, errors="strict"):
@@ -189,10 +186,7 @@ def tail(file_path, lines=10, encoding="utf-8", printed=True, errors="strict"):
189186

190187
with open(file_path, "rb") as f:
191188
for line in f:
192-
if python_version >= (2, 7):
193-
data.append(line.decode(encoding, errors=errors))
194-
else:
195-
data.append(line.decode(encoding))
189+
data.append(line.decode(encoding, errors=errors))
196190
if len(data) > lines:
197191
data.popleft()
198192
if printed:

reusables/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def test():
253253
# 2016-12-26 12:38:01,381 - reusables ERROR Exception in test - Bad
254254
# Traceback (most recent call last):
255255
# File "<input>", line 1, in <module>
256-
# File "reusables\wrappers.py", line 200, in wrapper
256+
# File "reusables/wrappers.py", line 200, in wrapper
257257
# raise err
258258
# Exception: Bad
259259

test/test_reuse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77

88
import reusables
9+
import pytest
910

1011
from .common_test_data import *
1112

@@ -431,6 +432,7 @@ def test_duplicate_dir(self):
431432
dups = reusables.directory_duplicates(test_root)
432433
assert len(dups) == 1, len(dups)
433434

435+
@pytest.mark.filterwarnings('ignore:"enable_scandir"')
434436
def test_find(self):
435437
resp = reusables.find_files_list(test_root, ext=[".cfg", ".nope"], disable_pathlib=True, enable_scandir=True)
436438
assert [x for x in resp if x.endswith(os.path.join(test_root, "test_config.cfg"))]

test/test_sanitized_input.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .common_test_data import *
1212

1313

14-
class TestException(Exception):
14+
class ReuseTestException(Exception):
1515
pass
1616

1717

@@ -20,7 +20,7 @@ def __init__(self, value):
2020
if isinstance(value, str):
2121
self.value = int(value)
2222
else:
23-
raise TestException("Exception")
23+
raise ReuseTestException("Exception")
2424

2525

2626
class TestSanitizedInput(BaseTestClass):
@@ -58,7 +58,7 @@ def test_cast_as(self):
5858
"raise_on_invalid": False,
5959
}
6060
with mock.patch("reusables.sanitizers._get_input", return_value=1):
61-
self.assertRaises(TestException, reusables.sanitized_input, **kwargs)
61+
self.assertRaises(ReuseTestException, reusables.sanitized_input, **kwargs)
6262
with mock.patch("reusables.sanitizers._get_input", return_value="1"):
6363
assert isinstance(reusables.sanitized_input(cast_as=IntVar), IntVar), "Success"
6464
assert not isinstance(reusables.sanitized_input(cast_as=IntVar), int), "Failure"

0 commit comments

Comments
 (0)