Skip to content

Commit

Permalink
Update to pass 'slyp' linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sirosen committed Dec 22, 2023
1 parent 050b6c7 commit f1a9af8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
16 changes: 10 additions & 6 deletions nose2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def setInitialArguments(self):
nargs="?",
action="append",
default=["unittest.cfg", "nose2.cfg"],
help="Config files to load, if they exist. ('unittest.cfg' "
"and 'nose2.cfg' in start directory default)",
help=(
"Config files to load, if they exist. ('unittest.cfg' "
"and 'nose2.cfg' in start directory default)"
),
)
self.argparse.add_argument(
"--no-user-config",
Expand All @@ -162,8 +164,10 @@ def setInitialArguments(self):
dest="load_plugins",
const=False,
default=True,
help="Do not load any plugins. Warning: nose2 does not "
"do anything if no plugins are loaded",
help=(
"Do not load any plugins. Warning: nose2 does not "
"do anything if no plugins are loaded"
),
)
self.argparse.add_argument(
"--plugin",
Expand All @@ -182,7 +186,7 @@ def setInitialArguments(self):
self.argparse.add_argument(
"--verbosity",
type=int,
help=("Set starting verbosity level (int). " "Applies before -v and -q"),
help=("Set starting verbosity level (int). Applies before -v and -q"),
)
self.argparse.add_argument(
"--verbose",
Expand All @@ -200,7 +204,7 @@ def setInitialArguments(self):
action="count",
default=0,
dest="quiet",
help=("Reduce verbosity. Multiple '-q's result in " "lower verbosity."),
help=("Reduce verbosity. Multiple '-q's result in lower verbosity."),
)
self.argparse.add_argument(
"--log-level",
Expand Down
6 changes: 4 additions & 2 deletions nose2/plugins/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def __init__(self):
metavar="TYPE",
choices=["term", "term-missing", "annotate", "html", "xml"],
dest="coverage_report",
help="Generate selected reports, available types:"
" term, term-missing, annotate, html, xml (multi-allowed)",
help=(
"Generate selected reports, available types:"
" term, term-missing, annotate, html, xml (multi-allowed)"
),
)
group.add_argument(
"--coverage-config",
Expand Down
12 changes: 8 additions & 4 deletions nose2/tests/functional/test_layers_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,17 @@ def test_layer_reporter_error_output(self):
r"ERROR: fixture with a value test_err \(test_layers_with_errors.Test"
+ _method_name("test_err")
+ r"\)",
"ERROR: A test scenario with errors should check for an attribute "
"that does not exist and raise an error",
(
"ERROR: A test scenario with errors should check for an attribute "
"that does not exist and raise an error"
),
r"FAIL: fixture with a value test_fail \(test_layers_with_errors.Test"
+ _method_name("test_fail")
+ r"\)",
"FAIL: A test scenario with errors should check that value == 2 "
"and fail",
(
"FAIL: A test scenario with errors should check that value == 2 "
"and fail"
),
]
for line in expect:
self.assertTestRunOutputMatches(proc, stderr=line)
Expand Down
4 changes: 2 additions & 2 deletions nose2/tests/functional/test_loadtests_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_package(self):
proc = self.runIn(
"scenario/load_tests_pkg",
"-v",
"-c=" "nose2/tests/functional/support/scenario/load_tests_pkg/unittest.cfg",
"-c=nose2/tests/functional/support/scenario/load_tests_pkg/unittest.cfg",
"--plugin=nose2.plugins.loader.loadtests",
)
self.assertTestRunOutputMatches(proc, stderr="Ran 2 tests")
Expand All @@ -34,7 +34,7 @@ def test_project_directory_inside_package(self):
proc = self.runIn(
"scenario/load_tests_pkg/ltpkg/tests",
"-v",
"-c=" "nose2/tests/functional/support/scenario/load_tests_pkg/unittest.cfg",
"-c=nose2/tests/functional/support/scenario/load_tests_pkg/unittest.cfg",
"--plugin=nose2.plugins.loader.loadtests",
)
self.assertTestRunOutputMatches(proc, stderr="Ran 1 test")
Expand Down
2 changes: 1 addition & 1 deletion nose2/tests/functional/test_such_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_load_sublayer_test_by_name(self):
"such",
"-v",
"--plugin=nose2.plugins.layers",
"test_such.having an expensive fixture." "should do more things",
"test_such.having an expensive fixture.should do more things",
)
self.assertTestRunOutputMatches(proc, stderr="Ran 1 test")
self.assertEqual(proc.poll(), 0, proc.stderr.getvalue())
Expand Down
6 changes: 3 additions & 3 deletions nose2/tests/unit/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _fromisoformat(date_str):
class TestJunitXmlPlugin(TestCase):
_RUN_IN_TEMP = True

BAD_FOR_XML_U = "A\x07 B\x0B C\x10 D\uD900 " "E\uFFFE F\x80 G\x90 H\uFDDD"
BAD_FOR_XML_U = "A\x07 B\x0B C\x10 D\uD900 E\uFFFE F\x80 G\x90 H\uFDDD"
# UTF-8 string with double null (invalid)
BAD_FOR_XML_B = (
b"A\x07 B\x0b C\x10 D\xed\xa4\x80 "
Expand Down Expand Up @@ -51,10 +51,10 @@ class TestJunitXmlPlugin(TestCase):
if sys.maxunicode <= 0xFFFF:
EXPECTED_RE = "^[\x09\x0A\x0D\x20\x21-\uD7FF\uE000-\uFFFD]*$"
EXPECTED_RE_SAFE = (
"^[\x09\x0A\x0D\x20\x21-\x7E\x85" "\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD]*$"
"^[\x09\x0A\x0D\x20\x21-\x7E\x85\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD]*$"
)
else:
EXPECTED_RE = "^[\x09\x0A\x0D\x20\x21-\uD7FF\uE000-\uFFFD" "\u10000-\u10FFFF]*$"
EXPECTED_RE = "^[\x09\x0A\x0D\x20\x21-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]*$"
EXPECTED_RE_SAFE = (
"^[\x09\x0A\x0D\x20\x21-\x7E\x85"
"\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD"
Expand Down
6 changes: 3 additions & 3 deletions nose2/tests/unit/test_printhooks_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_traces_hooks_created_after_own_registration(self):
result = self.session.hooks.pluginHookA(event)
self.assertEqual(result, "TestPluginB.pluginHookA")
self.assertEqual(
"\n" "pluginHookA: " "CustomEvent(handled=False, args='args')",
"\npluginHookA: CustomEvent(handled=False, args='args')",
self.buf.getvalue(),
)

Expand All @@ -87,7 +87,7 @@ def test_traces_hooks_created_before_own_registration(self):
result = self.session.hooks.pluginHookA(event)
self.assertEqual(result, "TestPluginB.pluginHookA")
self.assertEqual(
"\n" "pluginHookA: " "CustomEvent(handled=False, args='args')",
"\npluginHookA: CustomEvent(handled=False, args='args')",
self.buf.getvalue(),
)

Expand All @@ -99,7 +99,7 @@ def test_traces_hooks_that_nobody_implements(self):
result = self.session.hooks.pluginHookA(event)
self.assertEqual(result, None)
self.assertEqual(
"\n" "pluginHookA: " "CustomEvent(handled=False, args='args')",
"\npluginHookA: CustomEvent(handled=False, args='args')",
self.buf.getvalue(),
)

Expand Down
2 changes: 1 addition & 1 deletion nose2/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def is_not_base_class(c):
def safe_decode(string):
"""Safely decode a byte string into unicode"""
if string is None:
return string
return None
try:
return string.decode()
except AttributeError:
Expand Down

0 comments on commit f1a9af8

Please sign in to comment.