Skip to content

Commit b30a3a2

Browse files
[3.0.34] Fix python 3.8 syntax without black code format
1 parent e729be7 commit b30a3a2

File tree

3 files changed

+33
-47
lines changed

3 files changed

+33
-47
lines changed

test/TestUtils.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ def st_mode(self):
622622
getpwuid = getattr(WebScripts.utils, "getpwuid", None)
623623

624624
WebScripts.utils.user = "root"
625-
WebScripts.utils.getpwuid = lambda x: (
626-
Mock(pw_name="root") if x == 0 else Mock()
625+
WebScripts.utils.getpwuid = (
626+
lambda x: Mock(pw_name="root") if x == 0 else Mock()
627627
)
628628

629629
class SpecialMock(Mock):
@@ -634,14 +634,11 @@ def __call__(self, file):
634634
isfile = WebScripts.utils.isfile
635635
mock = WebScripts.utils.isfile = SpecialMock()
636636

637-
with (
638-
patch.object(
639-
WebScripts.utils, "stat", return_value=stat_response
640-
) as file,
641-
patch.object(
642-
WebScripts.utils, "isdir", return_value=True
643-
) as mock2,
644-
):
637+
with patch.object(
638+
WebScripts.utils, "stat", return_value=stat_response
639+
) as file, patch.object(
640+
WebScripts.utils, "isdir", return_value=True
641+
) as mock2:
645642
self.assertTrue(
646643
check_file_permission(config, "test/test", False, False, True)
647644
)

test/TestWebScripts.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ def test_set_default_headers(self):
335335

336336
Server.set_default_headers(h, True, c)
337337

338-
headers["Strict-Transport-Security"] = (
339-
"max-age=63072000; includeSubDomains; preload"
340-
)
338+
headers[
339+
"Strict-Transport-Security"
340+
] = "max-age=63072000; includeSubDomains; preload"
341341
headers["Content-Security-Policy"] = (
342342
"default-src 'self'; navigate-to 'self'; worker-src "
343343
"'none'; style-src-elem 'self'; style-src-attr 'none';"
@@ -352,19 +352,19 @@ def test_set_default_headers(self):
352352
headers["X-XSS-Protection"] = "1; mode=block"
353353
headers["X-Content-Type-Options"] = "nosniff"
354354
headers["Referrer-Policy"] = "origin-when-cross-origin"
355-
headers["Cache-Control"] = (
356-
"no-cache, no-store, must-revalidate, private"
357-
)
355+
headers[
356+
"Cache-Control"
357+
] = "no-cache, no-store, must-revalidate, private"
358358
headers["Pragma"] = "no-cache"
359359
headers["Expires"] = "0"
360360
headers["Clear-Site-Data"] = '"cache", "executionContexts"'
361361
headers["Feature-Policy"] = (
362362
"payment 'none'; geolocation 'none'; "
363363
"microphone 'none'; camera 'none'"
364364
)
365-
headers["Permissions-Policy"] = (
366-
"microphone=(),camera=(),payment=(),geolocation=()"
367-
)
365+
headers[
366+
"Permissions-Policy"
367+
] = "microphone=(),camera=(),payment=(),geolocation=()"
368368
headers["Cross-Origin-Embedder-Policy"] = "require-corp"
369369
headers["Cross-Origin-Opener-Policy"] = "same-origin"
370370
headers["Cross-Origin-Resource-Policy"] = "same-origin"
@@ -1538,11 +1538,9 @@ def test_get_server_config(self):
15381538
with patch.object(
15391539
WebScripts.WebScripts,
15401540
"system",
1541-
return_value=(
1542-
"Linux"
1543-
if WebScripts.WebScripts.system() == "Windows"
1544-
else "Windows"
1545-
),
1541+
return_value="Linux"
1542+
if WebScripts.WebScripts.system() == "Windows"
1543+
else "Windows",
15461544
) as mock_method:
15471545
for configurations in get_server_config(arguments):
15481546
self.assertTrue(isinstance(configurations, dict))
@@ -1568,14 +1566,9 @@ def test_logs_configuration(self):
15681566
def test_configure_logs_system(self):
15691567
global WebScripts
15701568

1571-
with (
1572-
patch.object(
1573-
WebScripts.WebScripts,
1574-
"check_file_permission",
1575-
return_value=False,
1576-
),
1577-
self.assertRaises(WebScriptsSecurityError),
1578-
):
1569+
with patch.object(
1570+
WebScripts.WebScripts, "check_file_permission", return_value=False
1571+
), self.assertRaises(WebScriptsSecurityError):
15791572
configure_logs_system()
15801573
self.assertTrue(path.isdir("logs"))
15811574
self.assertFalse(path.isfile(path.join("logs", "root.logs")))

test/TestWebScriptsImports.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,9 @@ def isdir(directory):
216216

217217
sys.modules["os"].mkdir = OsModule.mkdir
218218

219-
with (
220-
patch.object(sys.modules["os.path"], "isdir", return_value=False),
221-
patch.object(sys.modules["path"], "isdir", return_value=False),
222-
):
219+
with patch.object(
220+
sys.modules["os.path"], "isdir", return_value=False
221+
), patch.object(sys.modules["path"], "isdir", return_value=False):
223222
import WebScripts
224223

225224
real_check_file_permission = WebScripts.check_file_permission
@@ -375,17 +374,14 @@ def change_WINDOWS_LOGS(*args):
375374
# lambda *x, **y: "Linux" if system() == "Windows" else "Windows"
376375
# )
377376

378-
with (
379-
patch.object(
380-
sys.modules["platform"],
381-
"system",
382-
return_value=("Linux" if system() == "Windows" else "Windows"),
383-
),
384-
patch.object(
385-
sys.modules["subprocess"],
386-
"check_call",
387-
return_value=0,
388-
),
377+
with patch.object(
378+
sys.modules["platform"],
379+
"system",
380+
return_value=("Linux" if system() == "Windows" else "Windows"),
381+
), patch.object(
382+
sys.modules["subprocess"],
383+
"check_call",
384+
return_value=0,
389385
):
390386
utils.get_real_path("/test/whynot", no_error=True)
391387
_exec(utils.__spec__, utils)

0 commit comments

Comments
 (0)