99import logging
1010from six .moves import cStringIO
1111
12- import pkg_resources
1312from pytest import yield_fixture , fixture
1413import devpi_server as _devpi_server
1514from devpi .main import main as devpi_client
2019
2120@yield_fixture (scope = 'session' )
2221def 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.
2423 Out-of-the-box it creates a single user an index for that user, then
2524 uses that index.
26-
25+
2726 Methods
2827 -------
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:
3029 ... api('index', '-c', 'myindex') to create an index called 'myindex'
3130 ... api('getjson', '/user/myindex') to return the json string describing this index
32-
31+
3332 Attributes
3433 ----------
3534 uri: Server URI
@@ -38,9 +37,9 @@ def devpi_server(request):
3837 index: Initially created index name
3938 server_dir: Path to server database
4039 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+
4443 For more fine-grained control over these attributes, use the class directly and pass in
4544 constructor arguments.
4645 """
@@ -51,7 +50,7 @@ def devpi_server(request):
5150
5251@fixture
5352def 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.
5554 """
5655 index_name = '/' .join ((devpi_server .user , request .function .__name__ ))
5756 devpi_server .api ('index' , '-c' , index_name )
@@ -70,7 +69,7 @@ def __init__(self, offline=True, debug=False, data=None, user="testuser", passwo
7069 Run in offline mode. Defaults to True
7170 data: `str`
7271 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
7473 newly-created empty server.
7574 """
7675 self .debug = debug
@@ -89,7 +88,7 @@ def __init__(self, offline=True, debug=False, data=None, user="testuser", passwo
8988 @property
9089 def run_cmd (self ):
9190 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 ) ,
9392 '--host' , self .hostname ,
9493 '--port' , str (self .port )
9594 ]
@@ -104,7 +103,7 @@ def api(self, *args):
104103 """
105104 client_args = ['devpi' ]
106105 client_args .extend (args )
107- client_args .extend (['--clientdir' , self .client_dir ])
106+ client_args .extend (['--clientdir' , str ( self .client_dir ) ])
108107 log .info (' ' .join (client_args ))
109108 captured = cStringIO ()
110109 stdout = sys .stdout
@@ -119,10 +118,10 @@ def api(self, *args):
119118 def pre_setup (self ):
120119 if self .data :
121120 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 ) )
123122 else :
124123 self .run ([os .path .join (sys .exec_prefix , "bin" , "devpi-init" ),
125- '--serverdir' , self .server_dir ,
124+ '--serverdir' , str ( self .server_dir ) ,
126125 ])
127126
128127
0 commit comments