11import sys
22from pathlib import Path
33
4- HERE = Path (__file__ ).parent .resolve ()
54
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 ())
711
812# load the config object for traitlets based configuration
913c = get_config () # noqa
@@ -49,51 +53,51 @@ def my_env():
4953
5054c .ServerProxy .servers = {
5155 "python-http" : {
52- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
56+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
5357 },
5458 "python-http-abs" : {
55- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
59+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
5660 "absolute_url" : True ,
5761 },
5862 "python-http-port54321" : {
59- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
63+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
6064 "port" : 54321 ,
6165 },
6266 "python-http-mappath" : {
63- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
67+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
6468 "mappath" : {
6569 "/" : "/index.html" ,
6670 },
6771 },
6872 "python-http-mappathf" : {
69- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
73+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
7074 "mappath" : mappathf ,
7175 },
7276 "python-http-callable-env" : {
73- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
77+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
7478 "environment" : my_env ,
7579 },
7680 "python-websocket" : {
77- "command" : [sys .executable , "./tests/resources/ websocket.py" , "--port={port}" ],
81+ "command" : [sys .executable , _get_path ( " websocket.py") , "--port={port}" ],
7882 "request_headers_override" : {
7983 "X-Custom-Header" : "pytest-23456" ,
8084 },
8185 },
8286 "python-eventstream" : {
83- "command" : [sys .executable , "./tests/resources/ eventstream.py" , "--port={port}" ]
87+ "command" : [sys .executable , _get_path ( " eventstream.py") , "--port={port}" ]
8488 },
8589 "python-unix-socket-true" : {
8690 "command" : [
8791 sys .executable ,
88- "./tests/resources/ httpinfo.py" ,
92+ _get_path ( " httpinfo.py") ,
8993 "--unix-socket={unix_socket}" ,
9094 ],
9195 "unix_socket" : True ,
9296 },
9397 "python-unix-socket-file" : {
9498 "command" : [
9599 sys .executable ,
96- "./tests/resources/ httpinfo.py" ,
100+ _get_path ( " httpinfo.py") ,
97101 "--unix-socket={unix_socket}" ,
98102 ],
99103 "unix_socket" : "/tmp/jupyter-server-proxy-test-socket" ,
@@ -104,38 +108,38 @@ def my_env():
104108 "unix_socket" : "/tmp/jupyter-server-proxy-test-socket" ,
105109 },
106110 "python-request-headers" : {
107- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
111+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
108112 "request_headers_override" : {
109113 "X-Custom-Header" : "pytest-23456" ,
110114 },
111115 },
112116 "python-gzipserver" : {
113- "command" : [sys .executable , "./tests/resources/ gzipserver.py" , "{port}" ],
117+ "command" : [sys .executable , _get_path ( " gzipserver.py") , "{port}" ],
114118 },
115119 "python-http-rewrite-response" : {
116- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
120+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
117121 "rewrite_response" : translate_ciao ,
118122 "port" : 54323 ,
119123 },
120124 "python-chained-rewrite-response" : {
121- "command" : [sys .executable , "./tests/resources/ httpinfo.py" , "--port={port}" ],
125+ "command" : [sys .executable , _get_path ( " httpinfo.py") , "--port={port}" ],
122126 "rewrite_response" : [translate_ciao , hello_to_foo ],
123127 },
124128 "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}" ],
126130 "rewrite_response" : [dog_to_cat , cats_only ],
127131 },
128132 "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}" ],
130134 "rewrite_response" : [cats_only , dog_to_cat ],
131135 },
132136 "python-proxyto54321-no-command" : {"port" : 54321 },
133137 "python-rawsocket-tcp" : {
134- "command" : [sys .executable , "./tests/resources/ rawsocket.py" , "{port}" ],
138+ "command" : [sys .executable , _get_path ( " rawsocket.py") , "{port}" ],
135139 "raw_socket_proxy" : True ,
136140 },
137141 "python-rawsocket-unix" : {
138- "command" : [sys .executable , "./tests/resources/ rawsocket.py" , "{unix_socket}" ],
142+ "command" : [sys .executable , _get_path ( " rawsocket.py") , "{unix_socket}" ],
139143 "unix_socket" : True ,
140144 "raw_socket_proxy" : True ,
141145 },
0 commit comments