@@ -90,6 +90,11 @@ def setUpClass(cls):
90
90
# temporary files are always removed, even when exceptions occur.
91
91
cls .temporary_directory = tempfile .mkdtemp (dir = os .getcwd ())
92
92
93
+ # Needed because in some tests simple_server.py cannot be found.
94
+ # The reason is that the current working directory
95
+ # has been changed when executing a subprocess.
96
+ cls .SIMPLE_SERVER_PATH = os .path .join (os .getcwd (), 'simple_server.py' )
97
+
93
98
# Launch a SimpleHTTPServer (serves files in the current directory).
94
99
# Test cases will request metadata and target files that have been
95
100
# pre-generated in 'tuf/tests/repository_data', which will be served
@@ -98,7 +103,7 @@ def setUpClass(cls):
98
103
# as a delegated role 'targets/role1', three target files, five key files,
99
104
# etc.
100
105
cls .SERVER_PORT = random .randint (30000 , 45000 )
101
- command = ['python' , '-m' , 'tests.simple_server' , str (cls .SERVER_PORT )]
106
+ command = ['python' , cls . SIMPLE_SERVER_PATH , str (cls .SERVER_PORT )]
102
107
cls .server_process = subprocess .Popen (command , stderr = subprocess .PIPE )
103
108
logger .info ('\n \t Server process started.' )
104
109
logger .info ('\t Server process id: ' + str (cls .server_process .pid ))
@@ -1091,7 +1096,7 @@ def test_6_get_one_valid_targetinfo(self):
1091
1096
# The SimpleHTTPServer started in the setupclass has a tendency to
1092
1097
# timeout in Windows after a few tests.
1093
1098
SERVER_PORT = random .randint (30000 , 45000 )
1094
- command = ['python' , '-m' , 'tests.simple_server' , str (SERVER_PORT )]
1099
+ command = ['python' , self . SIMPLE_SERVER_PATH , str (SERVER_PORT )]
1095
1100
server_process = subprocess .Popen (command , stderr = subprocess .PIPE )
1096
1101
1097
1102
# NOTE: Following error is raised if a delay is not long enough:
@@ -1359,7 +1364,7 @@ def test_7_updated_targets(self):
1359
1364
# The SimpleHTTPServer started in the setupclass has a tendency to
1360
1365
# timeout in Windows after a few tests.
1361
1366
SERVER_PORT = random .randint (30000 , 45000 )
1362
- command = ['python' , '-m' , 'tests.simple_server' , str (SERVER_PORT )]
1367
+ command = ['python' , self . SIMPLE_SERVER_PATH , str (SERVER_PORT )]
1363
1368
server_process = subprocess .Popen (command , stderr = subprocess .PIPE )
1364
1369
1365
1370
# NOTE: Following error is raised if a delay is not long enough to allow
@@ -1491,7 +1496,7 @@ def test_8_remove_obsolete_targets(self):
1491
1496
# The SimpleHTTPServer started in the setupclass has a tendency to
1492
1497
# timeout in Windows after a few tests.
1493
1498
SERVER_PORT = random .randint (30000 , 45000 )
1494
- command = ['python' , '-m' , 'tests.simple_server' , str (SERVER_PORT )]
1499
+ command = ['python' , self . SIMPLE_SERVER_PATH , str (SERVER_PORT )]
1495
1500
server_process = subprocess .Popen (command , stderr = subprocess .PIPE )
1496
1501
1497
1502
# NOTE: Following error is raised if a delay is not long enough to allow
@@ -1824,6 +1829,11 @@ def setUp(self):
1824
1829
self .temporary_repository_root = self .make_temp_directory (directory =
1825
1830
self .temporary_directory )
1826
1831
1832
+ # Needed because in some tests simple_server.py cannot be found.
1833
+ # The reason is that the current working directory
1834
+ # has been changed when executing a subprocess.
1835
+ self .SIMPLE_SERVER_PATH = os .path .join (os .getcwd (), 'simple_server.py' )
1836
+
1827
1837
# The original repository, keystore, and client directories will be copied
1828
1838
# for each test case.
1829
1839
original_repository = os .path .join (original_repository_files , 'repository' )
@@ -1875,8 +1885,8 @@ def setUp(self):
1875
1885
self .SERVER_PORT = 30001
1876
1886
self .SERVER_PORT2 = 30002
1877
1887
1878
- command = ['python' , '-m' , 'tests.simple_server' , str (self .SERVER_PORT )]
1879
- command2 = ['python' , '-m' , 'tests.simple_server' , str (self .SERVER_PORT2 )]
1888
+ command = ['python' , self . SIMPLE_SERVER_PATH , str (self .SERVER_PORT )]
1889
+ command2 = ['python' , self . SIMPLE_SERVER_PATH , str (self .SERVER_PORT2 )]
1880
1890
1881
1891
self .server_process = subprocess .Popen (command , stderr = subprocess .PIPE ,
1882
1892
cwd = self .repository_directory )
0 commit comments