Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
flamenco-worker-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
flamenco-worker-python
Commits
e0ef84e6
Commit
e0ef84e6
authored
6 years ago
by
Sybren A. Stüvel
Browse files
Options
Downloads
Patches
Plain Diff
Use less shell-uoting-sensitive test values
The new values work on Windows too.
parent
6ad48a1e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_runner.py
+12
-13
12 additions, 13 deletions
tests/test_runner.py
with
12 additions
and
13 deletions
tests/test_runner.py
+
12
−
13
View file @
e0ef84e6
import
asyncio
import
logging
import
shlex
import
sys
from
pathlib
import
Path
from
unittest.mock
import
Mock
,
call
from
tests.abstract_worker_test
import
AbstractWorkerTest
executable
=
Path
(
sys
.
executable
).
as_posix
()
class
AbstractCommandTest
(
AbstractWorkerTest
):
def
setUp
(
self
):
...
...
@@ -74,12 +79,10 @@ class ExecCommandTest(AbstractCommandTest):
)
def
test_exec_python
(
self
):
import
shlex
import
sys
cmd
=
self
.
construct
()
# Use shlex to quote strings like this, so we're sure it's done well.
args
=
[
sys
.
executable
,
'
-c
'
,
r
'
print(
"
hello, this is two lines\nYes, really.
"
)
'
]
args
=
[
executable
,
'
-c
'
,
r
'
print(
"
hello, this is two lines\nYes, really.
"
)
'
]
settings
=
{
'
cmd
'
:
'
'
.
join
(
shlex
.
quote
(
s
)
for
s
in
args
)
}
...
...
@@ -95,7 +98,7 @@ class ExecCommandTest(AbstractCommandTest):
self
.
fworker
.
register_log
.
assert_has_calls
([
call
(
'
exec: Starting
'
),
call
(
'
Executing %s
'
,
'
%s -c
\'
print(
"
hello, this is two lines
\\
nYes, really.
"
)
\'
'
%
sys
.
executable
),
'
%s -c
\'
print(
"
hello, this is two lines
\\
nYes, really.
"
)
\'
'
%
executable
),
call
(
'
pid=%d > hello, this is two lines
'
%
pid
),
call
(
'
pid=%d > Yes, really.
'
%
pid
),
# note the logged line doesn't end in a newline
call
(
'
exec: Finished
'
),
...
...
@@ -108,13 +111,11 @@ class ExecCommandTest(AbstractCommandTest):
)
def
test_exec_invalid_utf
(
self
):
import
shlex
import
sys
cmd
=
self
.
construct
()
# Use shlex to quote strings like this, so we're sure it's done well.
# Writes an invalid sequence of continuation bytes.
args
=
[
sys
.
executable
,
'
-c
'
,
r
'
import sys; sys.stdout.buffer.write(b
"
\x80\x80\
x80
"
)
'
]
args
=
[
executable
,
'
-c
'
,
r
'
import sys; sys.stdout.buffer.write(b
ytes((0x80, 0x80, 0
x80
))
)
'
]
settings
=
{
'
cmd
'
:
'
'
.
join
(
shlex
.
quote
(
s
)
for
s
in
args
)
}
...
...
@@ -133,7 +134,7 @@ class ExecCommandTest(AbstractCommandTest):
self
.
fworker
.
register_log
.
assert_has_calls
([
call
(
'
exec: Starting
'
),
call
(
'
Executing %s
'
,
'
%s -c
\'
import sys; sys.stdout.buffer.write(b
"
\\
x80
\\
x80
\\
x80
"
)
\'
'
%
sys
.
executable
),
'
%s -c
\'
import sys; sys.stdout.buffer.write(b
ytes((0x80, 0x80, 0
x80
))
)
\'
'
%
executable
),
call
(
decode_err
),
])
...
...
@@ -141,12 +142,10 @@ class ExecCommandTest(AbstractCommandTest):
self
.
fworker
.
register_task_update
.
assert_called_with
(
activity
=
decode_err
)
def
test_exec_python_fails
(
self
):
import
shlex
import
sys
cmd
=
self
.
construct
()
# Use shlex to quote strings like this, so we're sure it's done well.
args
=
[
sys
.
executable
,
'
-c
'
,
r
'
raise SystemExit(
"
¡
FAIL
!
"
)
'
]
args
=
[
executable
,
'
-c
'
,
r
'
raise SystemExit(
"
FAIL
"
)
'
]
settings
=
{
'
cmd
'
:
'
'
.
join
(
shlex
.
quote
(
s
)
for
s
in
args
)
}
...
...
@@ -162,8 +161,8 @@ class ExecCommandTest(AbstractCommandTest):
self
.
fworker
.
register_log
.
assert_has_calls
([
call
(
'
exec: Starting
'
),
call
(
'
Executing %s
'
,
'
%s -c
\'
raise SystemExit(
"
¡
FAIL
!
"
)
\'
'
%
sys
.
executable
),
call
(
'
pid=%d >
¡
FAIL
!
'
%
pid
),
# note the logged line doesn't end in a newline
'
%s -c
\'
raise SystemExit(
"
FAIL
"
)
\'
'
%
executable
),
call
(
'
pid=%d > FAIL
'
%
pid
),
# note the logged line doesn't end in a newline
call
(
'
exec.(task_id=12345, command_idx=0): Error executing:
'
'
Command %s (pid=%d) failed with status 1
'
%
(
settings
[
'
cmd
'
],
pid
))
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment