Skip to content

Commit 7416858

Browse files
committed
Linting.
1 parent 8cbf04e commit 7416858

File tree

4 files changed

+41
-52
lines changed

4 files changed

+41
-52
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ repos:
3838
rev: v1.5.1
3939
hooks:
4040
- id: python-no-eval
41-
- id: python-use-type-annotations
4241

4342
- repo: https://github.com/asottile/pyupgrade
4443
rev: v1.5.1

domdf_python_tools/paths.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,7 @@ def load_json(
543543
"""
544544

545545
return json_library.loads( # type: ignore
546-
self.read_text(
547-
encoding=encoding,
548-
errors=errors,
549-
),
546+
self.read_text(encoding=encoding, errors=errors),
550547
**kwargs,
551548
)
552549

tests/test_testing.py

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,62 @@
66
from _pytest.mark import Mark, MarkDecorator
77

88
# this package
9-
from domdf_python_tools.testing import (
10-
count,
11-
generate_falsy_values,
12-
generate_truthy_values,
13-
testing_boolean_values,
14-
whitespace_perms,
15-
)
9+
from domdf_python_tools import testing
1610
from domdf_python_tools.utils import strtobool
1711

1812

1913
def test_count():
20-
assert isinstance(count(100), MarkDecorator)
21-
assert isinstance(count(100).mark, Mark)
22-
assert "count" in count(100).mark.args
23-
assert count(100).mark.args[0] == "count"
24-
assert count(100).mark.args[1] == range(0, 100)
14+
assert isinstance(testing.count(100), MarkDecorator)
15+
assert isinstance(testing.count(100).mark, Mark)
16+
assert "count" in testing.count(100).mark.args
17+
assert testing.count(100).mark.args[0] == "count"
18+
assert testing.count(100).mark.args[1] == range(0, 100)
2519

26-
assert count(10).mark.args[1] == range(0, 10)
27-
assert count(10, 5).mark.args[1] == range(5, 10) # order of count is "stop, start, step"
28-
assert count(10, 5, 2).mark.args[1] == range(5, 10, 2) # order of count is "stop, start, step"
20+
assert testing.count(10).mark.args[1] == range(0, 10)
21+
assert testing.count(10, 5).mark.args[1] == range(5, 10) # order of count is "stop, start, step"
22+
assert testing.count(10, 5, 2).mark.args[1] == range(5, 10, 2) # order of count is "stop, start, step"
2923

3024

3125
def test_whitespace_perms():
3226
random.seed(1234)
3327

34-
assert isinstance(whitespace_perms(), MarkDecorator)
35-
assert isinstance(whitespace_perms().mark, Mark)
36-
assert "char" in whitespace_perms().mark.args
37-
assert whitespace_perms().mark.args[0] == "char"
38-
assert len(whitespace_perms().mark.args[1]) == 20
39-
assert len(whitespace_perms(1).mark.args[1]) == 41
40-
assert len(whitespace_perms(.1).mark.args[1]) == 4
28+
assert isinstance(testing.whitespace_perms(), MarkDecorator)
29+
assert isinstance(testing.whitespace_perms().mark, Mark)
30+
assert "char" in testing.whitespace_perms().mark.args
31+
assert testing.whitespace_perms().mark.args[0] == "char"
32+
assert len(testing.whitespace_perms().mark.args[1]) == 20
33+
assert len(testing.whitespace_perms(1).mark.args[1]) == 41
34+
assert len(testing.whitespace_perms(.1).mark.args[1]) == 4
4135

42-
assert isinstance(whitespace_perms(.1).mark.args[1], list)
43-
assert isinstance(whitespace_perms(.1).mark.args[1][0], str)
36+
assert isinstance(testing.whitespace_perms(.1).mark.args[1], list)
37+
assert isinstance(testing.whitespace_perms(.1).mark.args[1][0], str)
4438

45-
assert whitespace_perms(.1).mark.args[1] == ['\n\t\r', '\r\t', '\t \n', '\n\r']
39+
assert testing.whitespace_perms(.1).mark.args[1] == ['\n\t\r', '\r\t', '\t \n', '\n\r']
4640

47-
for string in whitespace_perms().mark.args[1]:
41+
for string in testing.whitespace_perms().mark.args[1]:
4842
assert re.match(r"^\s*$", string)
4943

5044

5145
def test_testing_boolean_strings():
52-
assert isinstance(testing_boolean_values(), MarkDecorator)
53-
assert isinstance(testing_boolean_values().mark, Mark)
54-
assert "boolean_string, expected_boolean" in testing_boolean_values().mark.args
55-
assert testing_boolean_values().mark.args[0] == "boolean_string, expected_boolean"
56-
assert len(testing_boolean_values().mark.args[1]) == 28
57-
assert isinstance(testing_boolean_values().mark.args[1], list)
58-
assert isinstance(testing_boolean_values().mark.args[1][0], tuple)
59-
assert len(testing_boolean_values().mark.args[1][0]) == 2
60-
assert isinstance(testing_boolean_values().mark.args[1][0][0], bool)
61-
assert isinstance(testing_boolean_values().mark.args[1][0][1], bool)
62-
63-
for value, expects in testing_boolean_values().mark.args[1]:
46+
assert isinstance(testing.testing_boolean_values(), MarkDecorator)
47+
assert isinstance(testing.testing_boolean_values().mark, Mark)
48+
assert "boolean_string, expected_boolean" in testing.testing_boolean_values().mark.args
49+
assert testing.testing_boolean_values().mark.args[0] == "boolean_string, expected_boolean"
50+
assert len(testing.testing_boolean_values().mark.args[1]) == 28
51+
assert isinstance(testing.testing_boolean_values().mark.args[1], list)
52+
assert isinstance(testing.testing_boolean_values().mark.args[1][0], tuple)
53+
assert len(testing.testing_boolean_values().mark.args[1][0]) == 2
54+
assert isinstance(testing.testing_boolean_values().mark.args[1][0][0], bool)
55+
assert isinstance(testing.testing_boolean_values().mark.args[1][0][1], bool)
56+
57+
for value, expects in testing.testing_boolean_values().mark.args[1]:
6458
assert strtobool(value) is expects
6559

6660

6761
def test_generate_truthy():
6862
random.seed(1234)
6963

70-
assert list(generate_truthy_values()) == [
64+
assert list(testing.generate_truthy_values()) == [
7165
True,
7266
"True",
7367
"true",
@@ -84,7 +78,7 @@ def test_generate_truthy():
8478
1,
8579
]
8680

87-
assert list(generate_truthy_values(["bar"])) == [
81+
assert list(testing.generate_truthy_values(["bar"])) == [
8882
True,
8983
"True",
9084
"true",
@@ -102,13 +96,13 @@ def test_generate_truthy():
10296
"bar",
10397
]
10498

105-
assert list(generate_truthy_values(ratio=.3)) == ['1', 'yes', 'True', True]
99+
assert list(testing.generate_truthy_values(ratio=.3)) == ['1', 'yes', 'True', True]
106100

107101

108102
def test_generate_falsy():
109103
random.seed(1234)
110104

111-
assert list(generate_falsy_values()) == [
105+
assert list(testing.generate_falsy_values()) == [
112106
False,
113107
"False",
114108
"false",
@@ -125,8 +119,8 @@ def test_generate_falsy():
125119
0,
126120
]
127121

128-
assert list(generate_falsy_values(["bar"])) == [
122+
assert list(testing.generate_falsy_values(["bar"])) == [
129123
False, "False", "false", "falSE", 'n', 'N', "NO", "no", "nO", "OFF", "off", "oFF", '0', 0, "bar"
130124
]
131125

132-
assert list(generate_falsy_values(ratio=.3)) == ['0', 'no', 'False', False]
126+
assert list(testing.generate_falsy_values(ratio=.3)) == ['0', 'no', 'False', False]

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,8 @@ basepython = python3.6
111111
ignore_errors = true
112112
changedir = {toxinidir}
113113
deps =
114-
mypy
115-
-r{toxinidir}/tests/requirements.txt
116-
114+
mypy
115+
-r{toxinidir}/tests/requirements.txt
117116
commands = mypy domdf_python_tools tests
118117

119118

0 commit comments

Comments
 (0)