9
9
import logging
10
10
from six .moves import cStringIO
11
11
12
- import pkg_resources
13
12
from pytest import yield_fixture , fixture
14
13
import devpi_server as _devpi_server
15
14
from devpi .main import main as devpi_client
20
19
21
20
@yield_fixture (scope = 'session' )
22
21
def devpi_server (request ):
23
- """ Session-scoped Devpi server run in a subprocess, out of a temp dir.
22
+ """ Session-scoped Devpi server run in a subprocess, out of a temp dir.
24
23
Out-of-the-box it creates a single user an index for that user, then
25
24
uses that index.
26
-
25
+
27
26
Methods
28
27
-------
29
- api(): Client API method, directly bound to the devpi-client command-line tool. Examples:
28
+ api(): Client API method, directly bound to the devpi-client command-line tool. Examples:
30
29
... api('index', '-c', 'myindex') to create an index called 'myindex'
31
30
... api('getjson', '/user/myindex') to return the json string describing this index
32
-
31
+
33
32
Attributes
34
33
----------
35
34
uri: Server URI
@@ -38,9 +37,9 @@ def devpi_server(request):
38
37
index: Initially created index name
39
38
server_dir: Path to server database
40
39
client_dir: Path to client directory
41
-
42
- .. also inherits all attributes from the `workspace` fixture
43
-
40
+
41
+ .. also inherits all attributes from the `workspace` fixture
42
+
44
43
For more fine-grained control over these attributes, use the class directly and pass in
45
44
constructor arguments.
46
45
"""
@@ -51,7 +50,7 @@ def devpi_server(request):
51
50
52
51
@fixture
53
52
def devpi_function_index (request , devpi_server ):
54
- """ Creates and activates an index for your current test function.
53
+ """ Creates and activates an index for your current test function.
55
54
"""
56
55
index_name = '/' .join ((devpi_server .user , request .function .__name__ ))
57
56
devpi_server .api ('index' , '-c' , index_name )
@@ -70,7 +69,7 @@ def __init__(self, offline=True, debug=False, data=None, user="testuser", passwo
70
69
Run in offline mode. Defaults to True
71
70
data: `str`
72
71
Filesystem path to a zipfile archive of the initial server data directory.
73
- If not set and in offline mode, it uses a pre-canned snapshot of a
72
+ If not set and in offline mode, it uses a pre-canned snapshot of a
74
73
newly-created empty server.
75
74
"""
76
75
self .debug = debug
@@ -89,7 +88,7 @@ def __init__(self, offline=True, debug=False, data=None, user="testuser", passwo
89
88
@property
90
89
def run_cmd (self ):
91
90
res = [sys .executable , '-c' , 'import sys; from devpi_server.main import main; sys.exit(main())' ,
92
- '--serverdir' , self .server_dir ,
91
+ '--serverdir' , str ( self .server_dir ) ,
93
92
'--host' , self .hostname ,
94
93
'--port' , str (self .port )
95
94
]
@@ -104,7 +103,7 @@ def api(self, *args):
104
103
"""
105
104
client_args = ['devpi' ]
106
105
client_args .extend (args )
107
- client_args .extend (['--clientdir' , self .client_dir ])
106
+ client_args .extend (['--clientdir' , str ( self .client_dir ) ])
108
107
log .info (' ' .join (client_args ))
109
108
captured = cStringIO ()
110
109
stdout = sys .stdout
@@ -119,10 +118,10 @@ def api(self, *args):
119
118
def pre_setup (self ):
120
119
if self .data :
121
120
log .info ("Extracting initial server data from {}" .format (self .data ))
122
- zipfile .ZipFile (self .data , 'r' ).extractall (self .server_dir )
121
+ zipfile .ZipFile (self .data , 'r' ).extractall (str ( self .server_dir ) )
123
122
else :
124
123
self .run ([os .path .join (sys .exec_prefix , "bin" , "devpi-init" ),
125
- '--serverdir' , self .server_dir ,
124
+ '--serverdir' , str ( self .server_dir ) ,
126
125
])
127
126
128
127
0 commit comments