summaryrefslogtreecommitdiff
path: root/src/_pytest/pathlib.py
AgeCommit message (Collapse)Author
2020-12-22pathlib: missing type annotation for fnmatch_exRan Benita
2020-12-15Some py.path.local -> pathlib.PathRan Benita
2020-12-12Compare also paths on Windows when considering ImportPathMismatchErrorBruno Oliveira
On Windows, os.path.samefile returns false for paths mounted in UNC paths which point to the same location. I couldn't reproduce the actual case reported, but looking at the code it seems this commit should fix the issue. Fix #7678 Fix #8076
2020-10-31Merge pull request #7956 from csernazs/fix-7951Ran Benita
Fix handling recursive symlinks
2020-10-31Fix handling recursive symlinksCserna Zsolt
When pytest was run on a directory containing a recursive symlink it failed with ELOOP as the library was not able to determine the type of the direntry: src/_pytest/main.py:685: in collect if not direntry.is_file(): E OSError: [Errno 40] Too many levels of symbolic links: '/home/florian/proj/pytest/tests/recursive' This is fixed by handling ELOOP and other errors in the visit function in pathlib.py, so the entries whose is_file() call raises an OSError with the pre-defined list of error numbers will be exluded from the result. The _ignore_errors function was copied from Lib/pathlib.py of cpython 3.9. Fixes #7951
2020-10-31pathlib: fix symlinked directories not followed during collectionRan Benita
2020-10-28Increase temp dir deletion period to 3 days (#7914)Vasilis Gerakaris
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-10-03py36+: pyupgrade: py36+Anthony Sottile
2020-10-03py36+: remove rexport of Path and PurePathAnthony Sottile
2020-10-03py36+: update the target version of black to py36Anthony Sottile
2020-10-03Merge pull request #7817 from bluetech/fix-testpaths-bestrelpath2Ran Benita
terminal: fix crash in header reporting when absolute testpaths is used
2020-10-02py36+: remove pathlib2 compatibility shimAnthony Sottile
2020-09-29pathlib: improve comments on commonpath and bestrelpathRan Benita
2020-09-04Replace some usages of config.{rootdir,inifile} with config.{rootpath,inipath}Ran Benita
2020-08-06pathlib: add absolutepath() as alternative to Path.resolve()Ran Benita
Didn't call it absolute or absolute_path to avoid conflicts with possible variable names. Didn't call it abspath to avoid confusion with os.path.abspath.
2020-08-06pathlib: add analogues to py.path.local's bestrelpath and commonRan Benita
An equivalent for these py.path.local functions is needed for some upcoming py.path -> pathlib conversions.
2020-08-04typing: set warn_unreachableRan Benita
This makes mypy raise an error whenever it detects code which is statically unreachable, e.g. x: int if isinstance(x, str): ... # Statement is unreachable [unreachable] This is really neat and finds quite a few logic and typing bugs. Sometimes the code is intentionally unreachable in terms of types, e.g. raising TypeError when a function is given an argument with a wrong type. In these cases a `type: ignore[unreachable]` is needed, but I think it's a nice code hint.
2020-08-01Format docstrings in a consistent styleRan Benita
2020-07-25pathlib: make visit() independent of py.path.local, use os.scandirRan Benita
`os.scandir()`, introduced in Python 3.5, is much faster than `os.listdir()`. See https://www.python.org/dev/peps/pep-0471/. It also has a `DirEntry` which can be used to further reduce syscalls in some cases.
2020-07-25pathlib: replace py.path.local.visit() with our own functionRan Benita
Part of reducing dependency on `py`. Also enables upcoming improvements. In cases where there are simpler alternatives (in tests), I used those. What's left are a couple of uses in `_pytest.main` and `_pytest.python` and they only have modest requirements, so all of the featureful code from py is not needed.
2020-07-15Inaccessible lock files now imply temporary directories can't be removedBruno Oliveira
Fix #7500 Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-07-10cacheprovider: type annotationsRan Benita
2020-06-22config: improve typingRan Benita
2020-06-13Introduce --import-mode=importlib (#7246)Bruno Oliveira
Fix #5821 Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-11Suppress errors while removing tmpdir's lock filesBruno Oliveira
Fix #5456
2020-06-09Fix typopiotrhm
2020-06-09Replace cleanup_numbered_dir with atexit.registerpiotrhm
2020-06-08Fix issue where working dir becomes wrong on subst drive on Windows. Fixes ↵Fabio Zadrozny
#5965 (#6523) Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-05Type annotate misc functionsRan Benita
2020-06-02Fix removal of very long paths on Windows (#6755)Tor Colvin
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-03-27Change EnvironmentError, IOError to OSError - they are aliasesRan Benita
Since Python 3.3, these are aliases for OSError: https://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy
2019-11-07Fix order of format args with warningDaniel Hahler
2019-11-07on_rm_rf_error: ignore os.open (no warning)Daniel Hahler
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
2019-10-26Add type annotations to _pytest.pathlibRan Benita
At least the ones I was sure of.
2019-10-23Review rm_rf handling of FileNotFoundErrorsBruno Oliveira
2019-09-12Revert "Merge pull request #5792 from dynatrace-oss-contrib/bugfix/badcase"Bruno Oliveira
This reverts commit 955e54221008aba577ecbaefa15679f6777d3bf8, reversing changes made to 0215bcd84e900d9271558df98bed89f4b96187f8. Will attempt a simpler approach
2019-08-28Move _uniquepath to pathlib as unique_path.Christian Neumüller
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-04Merge pull request #5684 from nicoddemus/errno-nomoreAnthony Sottile
Use OSError subclasses instead of handling errno
2019-08-02Use OSError subclasses instead of handling errnoBruno Oliveira
2019-08-02Improve rm_rf to handle only known functionsDaniel Hahler
Warnings are emitted if we cannot safely remove paths. Fix #5626
2019-07-12Fix typosAlbert Tugushev
2019-07-11Fix rmtree to remove directories with read-only filesBruno Oliveira
Fix #5524
2019-06-24Switch from deprecated imp to importlibAnthony Sottile
2019-06-04Clean up u' prefixes and py2 bytes conversionsAnthony Sottile
2019-06-03pre-commit run pyupgrade --all-filesAnthony Sottile
2019-06-03pre-commit run reorder-python-imports --all-filesAnthony Sottile
2019-06-03pre-commit run fix-encoding-pragma --all-filesAnthony Sottile
2019-06-02Drop Python 2.7 and 3.4 supportBruno Oliveira
* Update setup.py requires and classifiers * Drop Python 2.7 and 3.4 from CI * Update docs dropping 2.7 and 3.4 support * Fix mock imports and remove tests related to pypi's mock module * Add py27 and 34 support docs to the sidebar * Remove usage of six from tmpdir * Remove six.PY* code blocks * Remove sys.version_info related code * Cleanup compat * Remove obsolete safe_str * Remove obsolete __unicode__ methods * Remove compat.PY35 and compat.PY36: not really needed anymore * Remove unused UNICODE_TYPES * Remove Jython specific code * Remove some Python 2 references from docs Related to #5275
2019-05-14Use fix-encoding-pragma pre-commit hookAnthony Sottile
2019-03-01Run isortDaniel Hahler