Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#691] Fail attempt to fix pynose test discover on Windows #703

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ Release notes for chevah.compat
===============================


1.2.1 - 2024-11-03
------------------

* Allow cleaning testing filesystem inside the Python default temporary
directory, `tempfile.tempdir`.


1.2.0 - 2024-10-26
--------------------
------------------

* Include nose_randomly extension. The extension is no longer maintained upstream.
It also removes the dependency on node.


1.1.2 - 2024-10-04
--------------------
------------------

* Update for python 3.12.
* Fix tearDown error handling.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = chevah-compat
version = 1.2.0
version = 1.2.1
maintainer = Adi Roiban
maintainer_email = adi.roiban@proatria.com
license = BSD
Expand Down
38 changes: 26 additions & 12 deletions src/chevah_compat/testing/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import re
import tempfile
import uuid

import six
Expand Down Expand Up @@ -265,22 +266,35 @@ def have_safe_path(path):
if path == '/':
return False

# Allow cleaning temporary directories.
if tempfile.tempdir and path.startswith(tempfile.tempdir):
return True

if os.name == 'posix':
# On Unix it is allowed to clean folder only in these
# folders.
if not path.startswith(('/srv', '/home', '/tmp')):
return False
if os.name == 'nt':
if path == 'c:\\':
return False
# Allow the windows temp.
if path.lower().startswith('c:\\windows\\temp'):

if path.startswith(('/srv', '/home', '/tmp')):
return True
# On Windows deny Windows or Program Files.
if 'Windows' in path:
return False
if 'Program Files' in path:
return False

return False

# We are on Windows.
if path == 'c:\\':
# Deny direct Windows root folder.
return False

# Allow the windows temp.
if path.lower().startswith('c:\\windows\\temp'):
return True

# On Windows deny Windows or Program Files.
if 'Windows' in path:
return False

if 'Program Files' in path:
return False

return True

if not have_safe_path(path):
Expand Down