Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
120e7af6
"vscode:/vscode.git/clone" did not exist on "bd693b698f948d4b786b1e00e9e4208caf4834d2"
Unverified
Commit
120e7af6
authored
Feb 27, 2023
by
Philip Meier
Committed by
GitHub
Feb 27, 2023
Browse files
fix assert_run_python_script on Windows (#7346)
parent
af048198
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
21 deletions
+10
-21
test/common_utils.py
test/common_utils.py
+10
-7
test/test_transforms.py
test/test_transforms.py
+0
-5
test/test_transforms_v2.py
test/test_transforms_v2.py
+0
-9
No files found.
test/common_utils.py
View file @
120e7af6
...
...
@@ -844,17 +844,20 @@ class InfoBase:
def
assert_run_python_script
(
source_code
):
"""Utility to check assertions in an independent Python subprocess.
The script provided in the source code should return 0 and not print
anything on stderr or stdout. Taken from scikit-learn test utils.
source_code (str): The Python source code to execute.
anything on stderr or stdout. Modified from scikit-learn test utils.
Args:
source_code (str): The Python source code to execute.
"""
with
tempfile
.
NamedTemporaryFile
(
mode
=
"wb"
)
as
f
:
f
.
write
(
source_code
.
encode
())
f
.
flush
()
with
get_tmp_dir
()
as
root
:
path
=
pathlib
.
Path
(
root
)
/
"main.py"
with
open
(
path
,
"w"
)
as
file
:
file
.
write
(
source_code
)
cmd
=
[
sys
.
executable
,
f
.
name
]
try
:
out
=
check_output
(
cmd
,
stderr
=
STDOUT
)
out
=
check_output
(
[
sys
.
executable
,
str
(
path
)]
,
stderr
=
STDOUT
)
except
CalledProcessError
as
e
:
raise
RuntimeError
(
f
"script errored with output:
\n
{
e
.
output
.
decode
()
}
"
)
if
out
!=
b
""
:
...
...
test/test_transforms.py
View file @
120e7af6
...
...
@@ -2,7 +2,6 @@ import math
import
os
import
random
import
re
import
sys
import
textwrap
import
warnings
from
functools
import
partial
...
...
@@ -2279,10 +2278,6 @@ def test_random_grayscale_with_grayscale_input():
),
)
@
pytest
.
mark
.
parametrize
(
"from_private"
,
(
True
,
False
))
@
pytest
.
mark
.
skipif
(
sys
.
platform
in
(
"win32"
,
"cygwin"
),
reason
=
"assert_run_python_script is broken on Windows. Possible fix in https://github.com/pytorch/vision/pull/7346"
,
)
def
test_functional_deprecation_warning
(
import_statement
,
from_private
):
if
from_private
:
import_statement
=
import_statement
.
replace
(
"functional"
,
"_functional"
)
...
...
test/test_transforms_v2.py
View file @
120e7af6
...
...
@@ -2,7 +2,6 @@ import itertools
import
pathlib
import
random
import
re
import
sys
import
textwrap
import
warnings
from
collections
import
defaultdict
...
...
@@ -2102,10 +2101,6 @@ def test_sanitize_bounding_boxes_errors():
),
)
@
pytest
.
mark
.
parametrize
(
"call_disable_warning"
,
(
True
,
False
))
@
pytest
.
mark
.
skipif
(
sys
.
platform
in
(
"win32"
,
"cygwin"
),
reason
=
"assert_run_python_script is broken on Windows. Possible fix in https://github.com/pytorch/vision/pull/7346"
,
)
def
test_warnings_v2_namespaces
(
import_statement
,
call_disable_warning
):
if
call_disable_warning
:
source
=
f
"""
...
...
@@ -2125,10 +2120,6 @@ def test_warnings_v2_namespaces(import_statement, call_disable_warning):
assert_run_python_script
(
textwrap
.
dedent
(
source
))
@
pytest
.
mark
.
skipif
(
sys
.
platform
in
(
"win32"
,
"cygwin"
),
reason
=
"assert_run_python_script is broken on Windows. Possible fix in https://github.com/pytorch/vision/pull/7346"
,
)
def
test_no_warnings_v1_namespace
():
source
=
"""
import warnings
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment