diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2017-10-23 18:43:40 -0700 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-10-23 18:43:40 -0700 |
commit | 77dc0e8e3c9dc1e3f22a09d52d930ee891983696 (patch) | |
tree | 852efb4813af4daceceac4811f072c1169792b9c | |
parent | c582cae70be592fffb10255a6f01421151463799 (diff) |
Better test dir cleanup
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | tests/conftest.py | 15 |
2 files changed, 5 insertions, 11 deletions
@@ -9,4 +9,3 @@ demos/*.log _build .coverage .cache -paramiko-test-target diff --git a/tests/conftest.py b/tests/conftest.py index f77c929f..ac83eacf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,7 +25,7 @@ logging.basicConfig( ) -def make_sftp_folder(client): +def make_sftp_folder(): """ Ensure expected target temp folder exists on the remote end. @@ -43,8 +43,7 @@ def make_sftp_folder(client): path = os.environ.get('TEST_FOLDER', 'paramiko-test-target') # Forcibly nuke this directory locally, since at the moment, the below # fixtures only ever run with a locally scoped stub test server. - if os.path.exists(path): - shutil.rmtree(path) + shutil.rmtree(path, ignore_errors=True) # Then create it anew, again locally, for the same reason. os.mkdir(path) return path @@ -94,12 +93,8 @@ def sftp(sftp_server): # TODO: how cleanest to make this available to tests? Doing it this way is # marginally less bad than the previous 'global'-using setup, but not by # much? - client.FOLDER = make_sftp_folder(client) + client.FOLDER = make_sftp_folder() # Yield client to caller yield client - # Clean up - # TODO: many SFTP tests like to close the client; to match old test suite - # behavior we'd need to recreate the entire client? Possibly better to just - # make the "it runs locally, dumbass" explicit & then just use stdlib to - # clean up? - #client.rmdir(client.FOLDER) + # Clean up - as in make_sftp_folder, we assume local-only exec for now. + shutil.rmtree(client.FOLDER, ignore_errors=True) |