Skip to content

Commit 9bb5592

Browse files
committed
Add test for one of the cases in Supervisor#291
1 parent c32cf22 commit 9bb5592

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[supervisord]
2+
loglevel=debug ; log level; default info; others: debug,warn,trace
3+
logfile=/tmp/issue-291a.log ; main log file; default $CWD/supervisord.log
4+
pidfile=/tmp/issue-291a.pid ; supervisord pidfile; default supervisord.pid
5+
nodaemon=true ; start in foreground if true; default false
6+
7+
[program:print_env]
8+
command=python %(here)s/print_env.py
9+
startsecs=0
10+
autorestart=false

supervisor/tests/test_end_to_end.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from __future__ import unicode_literals
33

44
import os
5-
import sys
65
import signal
6+
import sys
77
import unittest
88
import pkg_resources
99
from supervisor.compat import xmlrpclib
@@ -20,6 +20,22 @@
2020

2121
class EndToEndTests(BaseTestCase):
2222

23+
def test_issue_291a_percent_signs_in_original_env_are_preserved(self):
24+
"""When an environment variable whose value contains a percent sign is
25+
present in the environment before supervisord starts, the value is
26+
passed to the child without the percent sign being mangled."""
27+
key = "SUPERVISOR_TEST_1441B"
28+
val = "foo_%s_%_%%_%%%_%2_bar"
29+
filename = pkg_resources.resource_filename(__name__, 'fixtures/issue-291a.conf')
30+
args = ['-m', 'supervisor.supervisord', '-c', filename]
31+
try:
32+
os.environ[key] = val
33+
supervisord = pexpect.spawn(sys.executable, args, encoding='utf-8')
34+
self.addCleanup(supervisord.kill, signal.SIGINT)
35+
supervisord.expect_exact(key + "=" + val)
36+
finally:
37+
del os.environ[key]
38+
2339
def test_issue_550(self):
2440
"""When an environment variable is set in the [supervisord] section,
2541
it should be put into the environment of the subprocess."""

0 commit comments

Comments
 (0)