Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-pytest-datadir for
openSUSE:Factory checked in at 2025-11-07 18:16:47
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-datadir (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-datadir.new.1980 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-datadir"
Fri Nov 7 18:16:47 2025 rev:7 rq:1316015 version:1.8.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-datadir/python-pytest-datadir.changes
2025-05-06 16:38:52.853779196 +0200
+++
/work/SRC/openSUSE:Factory/.python-pytest-datadir.new.1980/python-pytest-datadir.changes
2025-11-07 18:16:47.929173996 +0100
@@ -1,0 +2,14 @@
+Wed Nov 5 18:21:24 UTC 2025 - Marius Grossu <[email protected]>
+
+- Update to 1.8.0:
+ * New lazy_shared_datadir fixture, which brings the same lazy
+ functionality as lazy_datadir for the shared directory.
+ * Fix LazyDataDir.joinpath typing to also support Path objects as
+ the right-hand side parameter.
+ * py.typed was added to the distribution, enabling users to use
+ LazyDataDir in type annotations
+ * Fixed bug using lazy_datadir to copy a file using a sub-directory
+ * New lazy_datadir fixture that lazily copies files when accessed
+ via joinpath or / operator
+
+-------------------------------------------------------------------
Old:
----
pytest_datadir-1.6.1.tar.gz
New:
----
_scmsync.obsinfo
build.specials.obscpio
pytest_datadir-1.8.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-datadir.spec ++++++
--- /var/tmp/diff_new_pack.O6i7Rb/_old 2025-11-07 18:16:48.569200857 +0100
+++ /var/tmp/diff_new_pack.O6i7Rb/_new 2025-11-07 18:16:48.569200857 +0100
@@ -18,7 +18,7 @@
%{?sle15_python_module_pythons}
Name: python-pytest-datadir
-Version: 1.6.1
+Version: 1.8.0
Release: 0
Summary: Plugin for test data directories and files
License: MIT
++++++ _scmsync.obsinfo ++++++
mtime: 1762431926
commit: 4dd75494efdebd738329df8f3daefa613f97f2174ce07bf022160b4e4ffeba77
url: https://src.opensuse.org/python-pytest/python-pytest-datadir.git
revision: 4dd75494efdebd738329df8f3daefa613f97f2174ce07bf022160b4e4ffeba77
projectscmsync: https://src.opensuse.org/python-pytest/_ObsPrj.git
++++++ build.specials.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.gitignore new/.gitignore
--- old/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ new/.gitignore 2025-11-06 13:30:34.000000000 +0100
@@ -0,0 +1 @@
+.osc
++++++ pytest_datadir-1.6.1.tar.gz -> pytest_datadir-1.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/.pre-commit-config.yaml
new/pytest_datadir-1.8.0/.pre-commit-config.yaml
--- old/pytest_datadir-1.6.1/.pre-commit-config.yaml 2025-02-07
19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/.pre-commit-config.yaml 2025-07-30
15:51:06.000000000 +0200
@@ -9,11 +9,11 @@
language: python
files: \.py$
- repo: https://github.com/asottile/reorder-python-imports
- rev: v3.14.0
+ rev: v3.15.0
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
- rev: 24.10.0
+ rev: 25.1.0
hooks:
- id: black
args: [--safe, --quiet]
@@ -39,7 +39,7 @@
- id: debug-statements
language_version: python3
- repo: https://github.com/PyCQA/flake8
- rev: 7.1.1
+ rev: 7.3.0
hooks:
- id: flake8
exclude: tests/data
@@ -48,3 +48,8 @@
- flake8-typing-imports==1.14.0
- flake8-builtins==2.1.0
- flake8-bugbear==23.1.20
+- repo: https://github.com/pre-commit/mirrors-mypy
+ rev: v1.17.0
+ hooks:
+ - id: mypy
+ files: ^(src/|tests/)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/CHANGELOG.rst
new/pytest_datadir-1.8.0/CHANGELOG.rst
--- old/pytest_datadir-1.6.1/CHANGELOG.rst 2025-02-07 19:29:07.000000000
+0100
+++ new/pytest_datadir-1.8.0/CHANGELOG.rst 2025-07-30 15:51:06.000000000
+0200
@@ -1,6 +1,36 @@
pytest-datadir
==============
+1.8.0
+-----
+
+*2025-07-30*
+
+- New ``lazy_shared_datadir`` fixture, which brings the same lazy
functionality as ``lazy_datadir`` for the *shared* directory.
+- Fix ``LazyDataDir.joinpath`` typing to also support ``Path`` objects as the
right-hand side parameter.
+
+1.7.2
+-----
+
+*2025-06-06*
+
+- ``py.typed`` was added to the distribution, enabling users to use
``LazyDataDir`` in type annotations.
+
+1.7.1
+-----
+
+*2025-06-02*
+
+- Fixed bug using ``lazy_datadir`` to copy a file using a sub-directory (e.g,
``lazy_datadir / 'subdir' / 'file.txt'``) (`#99
<https://github.com/gabrielcnr/pytest-datadir/issues/99>`__).
+
+1.7.0
+-----
+
+*2025-05-30*
+
+- New `lazy_datadir` fixture that lazily copies files when accessed via
`joinpath` or `/` operator.
+
+
1.6.1
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/PKG-INFO
new/pytest_datadir-1.8.0/PKG-INFO
--- old/pytest_datadir-1.6.1/PKG-INFO 2025-02-07 19:29:10.862479400 +0100
+++ new/pytest_datadir-1.8.0/PKG-INFO 2025-07-30 15:51:10.821933000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 2.2
+Metadata-Version: 2.4
Name: pytest-datadir
-Version: 1.6.1
+Version: 1.8.0
Summary: pytest plugin for test data directories and files
Author-email: Gabriel Reis <[email protected]>
License: MIT
@@ -28,6 +28,7 @@
Provides-Extra: dev
Requires-Dist: pytest-datadir[testing]; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
+Dynamic: license-file
# pytest-datadir
@@ -41,8 +42,10 @@
# Usage
-pytest-datadir will look up for a directory with the name of your module or
the global 'data' folder.
-Let's say you have a structure like this:
+
+`pytest-datadir` automatically looks for a directory matching your module's
name or a global `data` folder.
+
+Consider the following directory structure:
```
.
@@ -52,8 +55,11 @@
│ └── spam.txt
└── test_hello.py
```
-You can access the contents of these files using injected variables `datadir`
(for *test_* folder) or `shared_datadir`
-(for *data* folder):
+
+You can access file contents using the injected fixtures:
+
+- `datadir` (for module-specific `test_*` folders)
+- `shared_datadir` (for the global `data` folder)
```python
def test_read_global(shared_datadir):
@@ -66,9 +72,33 @@
assert contents == "eggs\n"
```
-pytest-datadir will copy the original file to a temporary folder, so changing
the file contents won't change the original data file.
+The contents of the data directory are copied to a temporary folder, ensuring
safe file modifications without affecting other tests or original files.
+
+Both `datadir` and `shared_datadir` fixtures return `pathlib.Path` objects.
-Both `datadir` and `shared_datadir` fixtures are `pathlib.Path` objects.
+## lazy_datadir
+
+Version 1.7.0 introduced the `lazy_datadir` fixture, which only copies files
and directories when accessed via the `joinpath` method or the `/` operator.
+
+```python
+def test_read_module(lazy_datadir):
+ contents = (lazy_datadir / "spam.txt").read_text()
+ assert contents == "eggs\n"
+```
+
+Unlike `datadir`, `lazy_datadir` is an object that only implements `joinpath`
and `/` operations. While not fully backward-compatible with `datadir`, most
tests can switch to `lazy_datadir` without modifications.
+
+### lazy_shared_datadir
+
+`lazy_shared_datadir` is similar to `lazy_datadir`, but applied to the shared
data directory `shared_datadir`.
+That is, instead of copying all files in `shared_datadir`, files are only
copied as necessary when accessed via `joinpath` or the `/` operator.
+This allows for a shared data directory to be pulled from lazily in the same
manner as `lazy_datadir`.
+
+```python
+def test_read_global(lazy_shared_datadir):
+ contents = (lazy_shared_datadir / "hello.txt").read_text()
+ assert contents == "Hello World!\n"
+```
# License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/README.md
new/pytest_datadir-1.8.0/README.md
--- old/pytest_datadir-1.6.1/README.md 2025-02-07 19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/README.md 2025-07-30 15:51:06.000000000 +0200
@@ -10,8 +10,10 @@
# Usage
-pytest-datadir will look up for a directory with the name of your module or
the global 'data' folder.
-Let's say you have a structure like this:
+
+`pytest-datadir` automatically looks for a directory matching your module's
name or a global `data` folder.
+
+Consider the following directory structure:
```
.
@@ -21,8 +23,11 @@
│ └── spam.txt
└── test_hello.py
```
-You can access the contents of these files using injected variables `datadir`
(for *test_* folder) or `shared_datadir`
-(for *data* folder):
+
+You can access file contents using the injected fixtures:
+
+- `datadir` (for module-specific `test_*` folders)
+- `shared_datadir` (for the global `data` folder)
```python
def test_read_global(shared_datadir):
@@ -35,9 +40,33 @@
assert contents == "eggs\n"
```
-pytest-datadir will copy the original file to a temporary folder, so changing
the file contents won't change the original data file.
+The contents of the data directory are copied to a temporary folder, ensuring
safe file modifications without affecting other tests or original files.
+
+Both `datadir` and `shared_datadir` fixtures return `pathlib.Path` objects.
-Both `datadir` and `shared_datadir` fixtures are `pathlib.Path` objects.
+## lazy_datadir
+
+Version 1.7.0 introduced the `lazy_datadir` fixture, which only copies files
and directories when accessed via the `joinpath` method or the `/` operator.
+
+```python
+def test_read_module(lazy_datadir):
+ contents = (lazy_datadir / "spam.txt").read_text()
+ assert contents == "eggs\n"
+```
+
+Unlike `datadir`, `lazy_datadir` is an object that only implements `joinpath`
and `/` operations. While not fully backward-compatible with `datadir`, most
tests can switch to `lazy_datadir` without modifications.
+
+### lazy_shared_datadir
+
+`lazy_shared_datadir` is similar to `lazy_datadir`, but applied to the shared
data directory `shared_datadir`.
+That is, instead of copying all files in `shared_datadir`, files are only
copied as necessary when accessed via `joinpath` or the `/` operator.
+This allows for a shared data directory to be pulled from lazily in the same
manner as `lazy_datadir`.
+
+```python
+def test_read_global(lazy_shared_datadir):
+ contents = (lazy_shared_datadir / "hello.txt").read_text()
+ assert contents == "Hello World!\n"
+```
# License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/RELEASING.rst
new/pytest_datadir-1.8.0/RELEASING.rst
--- old/pytest_datadir-1.6.1/RELEASING.rst 2025-02-07 19:29:07.000000000
+0100
+++ new/pytest_datadir-1.8.0/RELEASING.rst 2025-07-30 15:51:06.000000000
+0200
@@ -3,10 +3,8 @@
1. Create a ``release-VERSION`` branch from ``upstream/master``.
2. Update ``CHANGELOG.rst``.
3. Push the branch to ``upstream``.
-4. Once all tests pass, start the ``deploy`` workflow manually or via
command-line:
+4. Once all tests pass, start the ``deploy`` workflow manually or via
command-line::
- ```
- gh workflow run deploy.yml --ref release-VERSION --field version=VERSION
- ```
+ gh workflow run deploy.yml --ref release-VERSION --field version=VERSION
5. Merge the PR.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/pyproject.toml
new/pytest_datadir-1.8.0/pyproject.toml
--- old/pytest_datadir-1.6.1/pyproject.toml 2025-02-07 19:29:07.000000000
+0100
+++ new/pytest_datadir-1.8.0/pyproject.toml 2025-07-30 15:51:06.000000000
+0200
@@ -57,3 +57,21 @@
[tool.pytest.ini_options]
testpaths = ["tests"]
+
+[tool.setuptools.package-data]
+"pytest_datadir" = ["py.typed"]
+
+[tool.mypy]
+disallow_any_generics = true
+disallow_subclassing_any = true
+disallow_untyped_defs = true
+ignore_missing_imports = true
+no_implicit_optional = true
+pretty = true
+show_error_codes = true
+strict_equality = true
+warn_redundant_casts = true
+warn_return_any = true
+warn_unreachable = true
+warn_unused_configs = true
+warn_unused_ignores = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/src/pytest_datadir/_version.py
new/pytest_datadir-1.8.0/src/pytest_datadir/_version.py
--- old/pytest_datadir-1.6.1/src/pytest_datadir/_version.py 2025-02-07
19:29:10.000000000 +0100
+++ new/pytest_datadir-1.8.0/src/pytest_datadir/_version.py 2025-07-30
15:51:10.000000000 +0200
@@ -1,8 +1,13 @@
-# file generated by setuptools_scm
+# file generated by setuptools-scm
# don't change, don't track in version control
+
+__all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
+
TYPE_CHECKING = False
if TYPE_CHECKING:
- from typing import Tuple, Union
+ from typing import Tuple
+ from typing import Union
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
else:
VERSION_TUPLE = object
@@ -12,5 +17,5 @@
__version_tuple__: VERSION_TUPLE
version_tuple: VERSION_TUPLE
-__version__ = version = '1.6.1'
-__version_tuple__ = version_tuple = (1, 6, 1)
+__version__ = version = '1.8.0'
+__version_tuple__ = version_tuple = (1, 8, 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/src/pytest_datadir/plugin.py
new/pytest_datadir-1.8.0/src/pytest_datadir/plugin.py
--- old/pytest_datadir-1.6.1/src/pytest_datadir/plugin.py 2025-02-07
19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/src/pytest_datadir/plugin.py 2025-07-30
15:51:06.000000000 +0200
@@ -1,11 +1,14 @@
import os
import shutil
import sys
+from dataclasses import dataclass
+from pathlib import Path
+from typing import Union
import pytest
-def _win32_longpath(path):
+def _win32_longpath(path: str) -> str:
"""
Helper function to add the long path prefix for Windows, so that
shutil.copytree
won't fail while working with paths with 255+ chars.
@@ -31,7 +34,7 @@
@pytest.fixture
-def shared_datadir(request, tmp_path):
+def shared_datadir(request: pytest.FixtureRequest, tmp_path: Path) -> Path:
original_shared_path = os.path.join(request.fspath.dirname, "data")
temp_path = tmp_path / "data"
shutil.copytree(
@@ -41,12 +44,12 @@
@pytest.fixture(scope="module")
-def original_datadir(request):
- return request.path.parent / request.path.stem
+def original_datadir(request: pytest.FixtureRequest) -> Path:
+ return Path(request.path).with_suffix("")
@pytest.fixture
-def datadir(original_datadir, tmp_path):
+def datadir(original_datadir: Path, tmp_path: Path) -> Path:
result = tmp_path / original_datadir.stem
if original_datadir.is_dir():
shutil.copytree(
@@ -55,3 +58,81 @@
else:
result.mkdir()
return result
+
+
+@dataclass(frozen=True)
+class LazyDataDir:
+ """
+ A dataclass to represent a lazy data directory.
+
+ Unlike the datadir fixture, this class copies files and directories to the
+ temporary directory when requested via the `joinpath` method or the `/`
operator.
+ """
+
+ original_datadir: Path
+ tmp_path: Path
+
+ def joinpath(self, other: Union[Path, str]) -> Path:
+ """
+ Return `other` joined with the temporary directory.
+
+ If `other` exists in the data directory, the corresponding file or
directory is
+ copied to the temporary directory before being returned.
+
+ Note that the file or directory is only copied once per test.
Subsequent calls
+ with the same argument within the same test will not trigger another
copy.
+ """
+ original = self.original_datadir / other
+ target = self.tmp_path / other
+ if original.exists() and not target.exists():
+ if original.is_file():
+ target.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy(
+ _win32_longpath(str(original)),
_win32_longpath(str(target))
+ )
+ elif original.is_dir():
+ shutil.copytree(
+ _win32_longpath(str(original)),
_win32_longpath(str(target))
+ )
+ return target
+
+ def __truediv__(self, other: Union[Path, str]) -> Path:
+ return self.joinpath(other)
+
+
[email protected]
+def lazy_datadir(original_datadir: Path, tmp_path: Path) -> LazyDataDir:
+ """
+ Return a lazy data directory.
+
+ Here, "lazy" means that the temporary directory is initially created empty.
+
+ Files and directories are then copied from the data directory only when
first
+ accessed via the ``joinpath`` method or the ``/`` operator.
+
+ Args:
+ original_datadir: The original data directory.
+ tmp_path: Pytest's built-in fixture providing a temporary directory
path.
+ """
+ return LazyDataDir(original_datadir, tmp_path)
+
+
[email protected]
+def lazy_shared_datadir(request: pytest.FixtureRequest, tmp_path: Path) ->
LazyDataDir:
+ """
+ Return a lazy version of the shared data directory.
+
+ Here, "lazy" means that the temporary directory is initially created empty.
+
+ Files and directories are then copied from the data directory only when
first
+ accessed via the ``joinpath`` method or the ``/`` operator.
+
+ Args:
+ request: The Pytest fixture request object.
+ tmp_path: Pytest's built-in fixture providing a temporary directory
path.
+ """
+ original_shared_path = Path(os.path.join(request.fspath.dirname, "data"))
+ temp_path = tmp_path / "data"
+ temp_path.mkdir(parents=True, exist_ok=False)
+
+ return LazyDataDir(original_shared_path, temp_path)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest_datadir-1.6.1/src/pytest_datadir.egg-info/PKG-INFO
new/pytest_datadir-1.8.0/src/pytest_datadir.egg-info/PKG-INFO
--- old/pytest_datadir-1.6.1/src/pytest_datadir.egg-info/PKG-INFO
2025-02-07 19:29:10.000000000 +0100
+++ new/pytest_datadir-1.8.0/src/pytest_datadir.egg-info/PKG-INFO
2025-07-30 15:51:10.000000000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 2.2
+Metadata-Version: 2.4
Name: pytest-datadir
-Version: 1.6.1
+Version: 1.8.0
Summary: pytest plugin for test data directories and files
Author-email: Gabriel Reis <[email protected]>
License: MIT
@@ -28,6 +28,7 @@
Provides-Extra: dev
Requires-Dist: pytest-datadir[testing]; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
+Dynamic: license-file
# pytest-datadir
@@ -41,8 +42,10 @@
# Usage
-pytest-datadir will look up for a directory with the name of your module or
the global 'data' folder.
-Let's say you have a structure like this:
+
+`pytest-datadir` automatically looks for a directory matching your module's
name or a global `data` folder.
+
+Consider the following directory structure:
```
.
@@ -52,8 +55,11 @@
│ └── spam.txt
└── test_hello.py
```
-You can access the contents of these files using injected variables `datadir`
(for *test_* folder) or `shared_datadir`
-(for *data* folder):
+
+You can access file contents using the injected fixtures:
+
+- `datadir` (for module-specific `test_*` folders)
+- `shared_datadir` (for the global `data` folder)
```python
def test_read_global(shared_datadir):
@@ -66,9 +72,33 @@
assert contents == "eggs\n"
```
-pytest-datadir will copy the original file to a temporary folder, so changing
the file contents won't change the original data file.
+The contents of the data directory are copied to a temporary folder, ensuring
safe file modifications without affecting other tests or original files.
+
+Both `datadir` and `shared_datadir` fixtures return `pathlib.Path` objects.
-Both `datadir` and `shared_datadir` fixtures are `pathlib.Path` objects.
+## lazy_datadir
+
+Version 1.7.0 introduced the `lazy_datadir` fixture, which only copies files
and directories when accessed via the `joinpath` method or the `/` operator.
+
+```python
+def test_read_module(lazy_datadir):
+ contents = (lazy_datadir / "spam.txt").read_text()
+ assert contents == "eggs\n"
+```
+
+Unlike `datadir`, `lazy_datadir` is an object that only implements `joinpath`
and `/` operations. While not fully backward-compatible with `datadir`, most
tests can switch to `lazy_datadir` without modifications.
+
+### lazy_shared_datadir
+
+`lazy_shared_datadir` is similar to `lazy_datadir`, but applied to the shared
data directory `shared_datadir`.
+That is, instead of copying all files in `shared_datadir`, files are only
copied as necessary when accessed via `joinpath` or the `/` operator.
+This allows for a shared data directory to be pulled from lazily in the same
manner as `lazy_datadir`.
+
+```python
+def test_read_global(lazy_shared_datadir):
+ contents = (lazy_shared_datadir / "hello.txt").read_text()
+ assert contents == "Hello World!\n"
+```
# License
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest_datadir-1.6.1/src/pytest_datadir.egg-info/SOURCES.txt
new/pytest_datadir-1.8.0/src/pytest_datadir.egg-info/SOURCES.txt
--- old/pytest_datadir-1.6.1/src/pytest_datadir.egg-info/SOURCES.txt
2025-02-07 19:29:10.000000000 +0100
+++ new/pytest_datadir-1.8.0/src/pytest_datadir.egg-info/SOURCES.txt
2025-07-30 15:51:10.000000000 +0200
@@ -14,6 +14,7 @@
src/pytest_datadir/__init__.py
src/pytest_datadir/_version.py
src/pytest_datadir/plugin.py
+src/pytest_datadir/py.typed
src/pytest_datadir.egg-info/PKG-INFO
src/pytest_datadir.egg-info/SOURCES.txt
src/pytest_datadir.egg-info/dependency_links.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/tests/test_hello.py
new/pytest_datadir-1.8.0/tests/test_hello.py
--- old/pytest_datadir-1.6.1/tests/test_hello.py 2025-02-07
19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/tests/test_hello.py 2025-07-30
15:51:06.000000000 +0200
@@ -2,10 +2,11 @@
from pathlib import Path
import pytest
+from pytest_datadir.plugin import LazyDataDir
@pytest.fixture(autouse=True, scope="module")
-def create_long_file_path():
+def create_long_file_path() -> None:
"""
Create a very long file name to ensure datadir can copy it correctly.
@@ -21,7 +22,7 @@
os.chdir(old_cwd)
-def test_read_hello(datadir):
+def test_read_hello(datadir: Path) -> None:
assert set(os.listdir(str(datadir))) == {
"local_directory",
"hello.txt",
@@ -33,7 +34,12 @@
assert contents == "Hello, world!\n"
-def test_change_test_files(datadir, original_datadir, shared_datadir, request):
+def test_change_test_files(
+ datadir: Path,
+ original_datadir: Path,
+ shared_datadir: Path,
+ request: pytest.FixtureRequest,
+) -> None:
filename = datadir / "hello.txt"
with filename.open("w") as fp:
fp.write("Modified text!\n")
@@ -53,14 +59,14 @@
assert fp.read().strip() == "8000"
-def test_read_spam_from_other_dir(shared_datadir):
+def test_read_spam_from_other_dir(shared_datadir: Path) -> None:
filename = shared_datadir / "spam.txt"
with filename.open() as fp:
contents = fp.read()
assert contents == "eggs\n"
-def test_file_override(shared_datadir, datadir):
+def test_file_override(shared_datadir: Path, datadir: Path) -> None:
"""The same file is in the module dir and global data.
Shared files are kept in a different temp directory"""
shared_filepath = shared_datadir / "over.txt"
@@ -70,7 +76,7 @@
assert shared_filepath != private_filepath
-def test_local_directory(datadir):
+def test_local_directory(datadir: Path) -> None:
directory = datadir / "local_directory"
assert directory.is_dir()
filename = directory / "file.txt"
@@ -80,10 +86,108 @@
assert contents.strip() == "local contents"
-def test_shared_directory(shared_datadir):
+def test_shared_directory(shared_datadir: Path) -> None:
assert shared_datadir.is_dir()
filename = shared_datadir / "shared_directory" / "file.txt"
assert filename.is_file()
with filename.open() as fp:
contents = fp.read()
assert contents.strip() == "global contents"
+
+
+def test_lazy_copy(lazy_datadir: LazyDataDir) -> None:
+ # The temporary directory starts empty.
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == set()
+
+ # Lazy copy file.
+ hello = lazy_datadir / "hello.txt"
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == {"hello.txt"}
+ assert hello.read_text() == "Hello, world!\n"
+
+ # Accessing the same file multiple times does not copy the file again.
+ hello.write_text("Hello world, hello world.")
+ hello = lazy_datadir / Path("hello.txt")
+ assert hello.read_text() == "Hello world, hello world."
+
+ # Lazy copy data directory.
+ local_dir = lazy_datadir / "local_directory"
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == {
+ "hello.txt",
+ "local_directory",
+ }
+ assert local_dir.is_dir() is True
+ assert local_dir.joinpath("file.txt").read_text() == "local contents"
+
+ # It is OK to request a file that does not exist in the data directory.
+ fn = lazy_datadir / "new-file.txt"
+ assert fn.exists() is False
+ fn.write_text("new contents")
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == {
+ "hello.txt",
+ "local_directory",
+ "new-file.txt",
+ }
+
+
+def test_lazy_copy_sub_directory(lazy_datadir: LazyDataDir) -> None:
+ """Copy via file by using a sub-directory (#99)."""
+ # The temporary directory starts empty.
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == set()
+
+ # Lazy copy file in a sub-directory.
+ fn = lazy_datadir / "local_directory/file.txt"
+ assert {x.name for x in lazy_datadir.tmp_path.iterdir()} == {
+ "local_directory",
+ }
+ assert fn.read_text() == "local contents"
+
+
+def test_shared_lazy_copy(lazy_shared_datadir: LazyDataDir, tmp_path: Path) ->
None:
+ # The temporary directory starts containing only an empty data directory.
+ assert {x.name for x in tmp_path.iterdir()} == {"data"}
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} == set()
+
+ # Lazy copy file.
+ spam = lazy_shared_datadir / "spam.txt"
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} ==
{"spam.txt"}
+ assert spam.read_text() == "eggs\n"
+
+ # Accessing the same file multiple times does not copy the file again.
+ spam.write_text("eggs and ham\n")
+ spam = lazy_shared_datadir / Path("spam.txt")
+ assert spam.read_text() == "eggs and ham\n"
+
+ # Lazy copy data directory.
+ shared_dir = lazy_shared_datadir / "shared_directory"
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} == {
+ "spam.txt",
+ "shared_directory",
+ }
+ assert shared_dir.is_dir() is True
+ assert shared_dir.joinpath("file.txt").read_text() == "global contents"
+
+ # It is OK to request a file that does not exist in the data directory.
+ fn = lazy_shared_datadir / "new-file.txt"
+ assert fn.exists() is False
+ fn.write_text("new contents")
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} == {
+ "spam.txt",
+ "shared_directory",
+ "new-file.txt",
+ }
+
+
+def test_shared_lazy_copy_sub_directory(
+ lazy_shared_datadir: LazyDataDir, tmp_path: Path
+) -> None:
+ """Copy via file by using a sub-directory (#99)."""
+ # The temporary directory starts containing only an empty data directory.
+ assert {x.name for x in tmp_path.iterdir()} == {"data"}
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} == set()
+
+ # Lazy copy file in a sub-directory.
+ fn = lazy_shared_datadir / "shared_directory/file.txt"
+ assert {x.name for x in lazy_shared_datadir.tmp_path.iterdir()} == {
+ "shared_directory",
+ }
+ assert fn.read_text() == "global contents"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/tests/test_nonexistent.py
new/pytest_datadir-1.8.0/tests/test_nonexistent.py
--- old/pytest_datadir-1.6.1/tests/test_nonexistent.py 2025-02-07
19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/tests/test_nonexistent.py 2025-07-30
15:51:06.000000000 +0200
@@ -1,2 +1,5 @@
-def test_missing_data_dir_starts_empty(datadir):
+from pathlib import Path
+
+
+def test_missing_data_dir_starts_empty(datadir: Path) -> None:
assert list(datadir.iterdir()) == []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest_datadir-1.6.1/tests/test_pathlib.py
new/pytest_datadir-1.8.0/tests/test_pathlib.py
--- old/pytest_datadir-1.6.1/tests/test_pathlib.py 2025-02-07
19:29:07.000000000 +0100
+++ new/pytest_datadir-1.8.0/tests/test_pathlib.py 2025-07-30
15:51:06.000000000 +0200
@@ -1,10 +1,11 @@
import sys
+from pathlib import Path
import pytest
from pytest_datadir.plugin import _win32_longpath
-def test_win32_longpath_idempotent(datadir):
+def test_win32_longpath_idempotent(datadir: Path) -> None:
"""Double application should not prepend twice."""
first = _win32_longpath(str(datadir))
second = _win32_longpath(first)
@@ -14,7 +15,7 @@
@pytest.mark.skipif(
not sys.platform.startswith("win"), reason="Only makes sense on Windows"
)
-def test_win32_longpath_unc(datadir):
+def test_win32_longpath_unc(datadir: Path) -> None:
unc_path = r"\\ComputerName\SharedFolder\Resource"
longpath = _win32_longpath(unc_path)
assert longpath.startswith("\\\\?\\UNC\\")