1
1
import sys
2
2
from pathlib import Path
3
3
4
- HERE = Path (__file__ ).parent .resolve ()
5
4
6
- sys .path .append (str (HERE ))
5
+ def _get_path (* args ):
6
+ """Resolve a path relative to this file"""
7
+ return str (Path (__file__ ).parent .resolve ().joinpath (* args ))
8
+
9
+
10
+ sys .path .append (_get_path ())
7
11
8
12
# load the config object for traitlets based configuration
9
13
c = get_config () # noqa
@@ -49,51 +53,51 @@ def my_env():
49
53
50
54
c .ServerProxy .servers = {
51
55
"python-http" : {
52
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
56
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
53
57
},
54
58
"python-http-abs" : {
55
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
59
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
56
60
"absolute_url" : True ,
57
61
},
58
62
"python-http-port54321" : {
59
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
63
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
60
64
"port" : 54321 ,
61
65
},
62
66
"python-http-mappath" : {
63
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
67
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
64
68
"mappath" : {
65
69
"/" : "/index.html" ,
66
70
},
67
71
},
68
72
"python-http-mappathf" : {
69
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
73
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
70
74
"mappath" : mappathf ,
71
75
},
72
76
"python-http-callable-env" : {
73
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
77
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
74
78
"environment" : my_env ,
75
79
},
76
80
"python-websocket" : {
77
- "command" : [sys .executable , "./tests/resources/ websocket.py" , "--port={port}" ],
81
+ "command" : [sys .executable , _get_path ( " websocket.py") , "--port={port}" ],
78
82
"request_headers_override" : {
79
83
"X-Custom-Header" : "pytest-23456" ,
80
84
},
81
85
},
82
86
"python-eventstream" : {
83
- "command" : [sys .executable , "./tests/resources/ eventstream.py" , "--port={port}" ]
87
+ "command" : [sys .executable , _get_path ( " eventstream.py") , "--port={port}" ]
84
88
},
85
89
"python-unix-socket-true" : {
86
90
"command" : [
87
91
sys .executable ,
88
- "./tests/resources/ httpinfo.py" ,
92
+ _get_path ( " httpinfo.py") ,
89
93
"--unix-socket={unix_socket}" ,
90
94
],
91
95
"unix_socket" : True ,
92
96
},
93
97
"python-unix-socket-file" : {
94
98
"command" : [
95
99
sys .executable ,
96
- "./tests/resources/ httpinfo.py" ,
100
+ _get_path ( " httpinfo.py") ,
97
101
"--unix-socket={unix_socket}" ,
98
102
],
99
103
"unix_socket" : "/tmp/jupyter-server-proxy-test-socket" ,
@@ -104,38 +108,38 @@ def my_env():
104
108
"unix_socket" : "/tmp/jupyter-server-proxy-test-socket" ,
105
109
},
106
110
"python-request-headers" : {
107
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
111
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
108
112
"request_headers_override" : {
109
113
"X-Custom-Header" : "pytest-23456" ,
110
114
},
111
115
},
112
116
"python-gzipserver" : {
113
- "command" : [sys .executable , "./tests/resources/ gzipserver.py" , "{port}" ],
117
+ "command" : [sys .executable , _get_path ( " gzipserver.py") , "{port}" ],
114
118
},
115
119
"python-http-rewrite-response" : {
116
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
120
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
117
121
"rewrite_response" : translate_ciao ,
118
122
"port" : 54323 ,
119
123
},
120
124
"python-chained-rewrite-response" : {
121
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
125
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
122
126
"rewrite_response" : [translate_ciao , hello_to_foo ],
123
127
},
124
128
"python-cats-only-rewrite-response" : {
125
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
129
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
126
130
"rewrite_response" : [dog_to_cat , cats_only ],
127
131
},
128
132
"python-dogs-only-rewrite-response" : {
129
- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
133
+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
130
134
"rewrite_response" : [cats_only , dog_to_cat ],
131
135
},
132
136
"python-proxyto54321-no-command" : {"port" : 54321 },
133
137
"python-rawsocket-tcp" : {
134
- "command" : [sys .executable , "./tests/resources/ rawsocket.py" , "{port}" ],
138
+ "command" : [sys .executable , _get_path ( " rawsocket.py") , "{port}" ],
135
139
"raw_socket_proxy" : True ,
136
140
},
137
141
"python-rawsocket-unix" : {
138
- "command" : [sys .executable , "./tests/resources/ rawsocket.py" , "{unix_socket}" ],
142
+ "command" : [sys .executable , _get_path ( " rawsocket.py") , "{unix_socket}" ],
139
143
"unix_socket" : True ,
140
144
"raw_socket_proxy" : True ,
141
145
},
0 commit comments