sparkless-testing 0.1.0__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sparkless_testing-0.1.0/sparkless_testing.egg-info → sparkless_testing-0.2.0}/PKG-INFO +1 -23
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/README.md +0 -19
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/pyproject.toml +7 -10
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/__init__.py +1 -1
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/parametrize.py +1 -2
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/pytest_fixtures.py +2 -4
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/session.py +1 -19
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0/sparkless_testing.egg-info}/PKG-INFO +1 -23
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/requires.txt +0 -4
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/tests/test_session.py +0 -81
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/LICENSE +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/setup.cfg +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/conftest.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/engine.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/protocols.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/py.typed +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing/utils.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/SOURCES.txt +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/dependency_links.txt +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/top_level.txt +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/tests/test_engine.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/tests/test_fixtures.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/tests/test_parametrize.py +0 -0
- {sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sparkless-testing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Easy testing with sparkless or PySpark on demand
|
|
5
5
|
Author-email: Odos Matthews <odosmatthews@gmail.com>
|
|
6
6
|
Maintainer-email: Odos Matthews <odosmatthews@gmail.com>
|
|
@@ -27,8 +27,6 @@ Provides-Extra: mock
|
|
|
27
27
|
Requires-Dist: sparkless>=3.19.0; extra == "mock"
|
|
28
28
|
Provides-Extra: pyspark
|
|
29
29
|
Requires-Dist: pyspark<3.6.0,>=3.5.0; extra == "pyspark"
|
|
30
|
-
Provides-Extra: delta
|
|
31
|
-
Requires-Dist: delta-spark<4.0.0,>=3.0.0; extra == "delta"
|
|
32
30
|
Provides-Extra: dev
|
|
33
31
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
32
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -36,7 +34,6 @@ Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
|
36
34
|
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
37
35
|
Requires-Dist: sparkless>=3.19.0; extra == "dev"
|
|
38
36
|
Requires-Dist: pyspark<3.6.0,>=3.5.0; extra == "dev"
|
|
39
|
-
Requires-Dist: delta-spark<4.0.0,>=3.0.0; extra == "dev"
|
|
40
37
|
Dynamic: license-file
|
|
41
38
|
|
|
42
39
|
# sparkless-testing
|
|
@@ -77,9 +74,6 @@ pip install sparkless-testing[mock]
|
|
|
77
74
|
# Install with PySpark engine
|
|
78
75
|
pip install sparkless-testing[pyspark]
|
|
79
76
|
|
|
80
|
-
# Install with Delta Lake support
|
|
81
|
-
pip install sparkless-testing[delta]
|
|
82
|
-
|
|
83
77
|
# Install with all engines
|
|
84
78
|
pip install sparkless-testing[dev]
|
|
85
79
|
```
|
|
@@ -208,7 +202,6 @@ spark = create_session(engine_type=EngineType.MOCK)
|
|
|
208
202
|
# Create session with custom configuration
|
|
209
203
|
config = SessionConfig(
|
|
210
204
|
app_name="my-test",
|
|
211
|
-
enable_delta=True,
|
|
212
205
|
shuffle_partitions=2,
|
|
213
206
|
)
|
|
214
207
|
spark = create_pyspark_session(config=config)
|
|
@@ -234,7 +227,6 @@ spark.stop()
|
|
|
234
227
|
- `SessionConfig`: Configuration dataclass for session creation
|
|
235
228
|
- `app_name`: Application name for the Spark session
|
|
236
229
|
- `warehouse_dir`: Custom warehouse directory (optional)
|
|
237
|
-
- `enable_delta`: Enable Delta Lake support (default: `True` for programmatic use, `False` in test fixtures)
|
|
238
230
|
- `enable_ui`: Enable Spark UI (default: `False`)
|
|
239
231
|
- `shuffle_partitions`: Number of shuffle partitions (default: `1`)
|
|
240
232
|
- `parallelism`: Default parallelism (default: `1`)
|
|
@@ -256,8 +248,6 @@ spark.stop()
|
|
|
256
248
|
- `spark_types`: Types module for current engine
|
|
257
249
|
- `spark_engine_type`: Current engine type as string (`"mock"` or `"pyspark"`)
|
|
258
250
|
|
|
259
|
-
**Note**: Test fixtures automatically disable Delta Lake for parallel testing compatibility. To use Delta Lake, create sessions programmatically with `enable_delta=True` in `SessionConfig`.
|
|
260
|
-
|
|
261
251
|
## Advanced Usage
|
|
262
252
|
|
|
263
253
|
### Custom Session Configuration
|
|
@@ -269,7 +259,6 @@ def test_with_custom_config():
|
|
|
269
259
|
config = SessionConfig(
|
|
270
260
|
app_name="custom-test",
|
|
271
261
|
warehouse_dir="/tmp/my-warehouse",
|
|
272
|
-
enable_delta=True,
|
|
273
262
|
enable_ui=True,
|
|
274
263
|
shuffle_partitions=4,
|
|
275
264
|
parallelism=4,
|
|
@@ -290,7 +279,6 @@ pytest -n auto # Auto-detect worker count
|
|
|
290
279
|
**Best Practices for Parallel Testing:**
|
|
291
280
|
- Mock (sparkless) tests can run with high parallelism (`-n 10+`)
|
|
292
281
|
- PySpark tests work best with fewer workers (`-n 2` or `-n 4`)
|
|
293
|
-
- Test fixtures automatically disable Delta Lake to avoid conflicts
|
|
294
282
|
- Each test gets a unique session name and warehouse directory
|
|
295
283
|
|
|
296
284
|
### Using Test Utilities
|
|
@@ -367,15 +355,6 @@ If tests hang when using `pytest -n`, try:
|
|
|
367
355
|
- Run PySpark tests sequentially: `pytest -n 0` for PySpark-only tests
|
|
368
356
|
- Use mock engine for faster parallel execution: `SPARK_MODE=mock pytest -n 10`
|
|
369
357
|
|
|
370
|
-
### Delta Lake Not Available
|
|
371
|
-
|
|
372
|
-
Delta Lake is disabled by default in test fixtures. To enable:
|
|
373
|
-
```python
|
|
374
|
-
from sparkless_testing import SessionConfig, create_pyspark_session
|
|
375
|
-
|
|
376
|
-
config = SessionConfig(app_name="test", enable_delta=True)
|
|
377
|
-
spark = create_pyspark_session(config=config)
|
|
378
|
-
```
|
|
379
358
|
|
|
380
359
|
### SparkContext Errors
|
|
381
360
|
|
|
@@ -427,7 +406,6 @@ def test_my_function(spark_session):
|
|
|
427
406
|
Optional:
|
|
428
407
|
- sparkless>=3.19.0 (for mock engine)
|
|
429
408
|
- pyspark>=3.5.0 (for real engine)
|
|
430
|
-
- delta-spark>=3.0.0 (for Delta Lake support)
|
|
431
409
|
- pytest-xdist (for parallel test execution)
|
|
432
410
|
|
|
433
411
|
## License
|
|
@@ -36,9 +36,6 @@ pip install sparkless-testing[mock]
|
|
|
36
36
|
# Install with PySpark engine
|
|
37
37
|
pip install sparkless-testing[pyspark]
|
|
38
38
|
|
|
39
|
-
# Install with Delta Lake support
|
|
40
|
-
pip install sparkless-testing[delta]
|
|
41
|
-
|
|
42
39
|
# Install with all engines
|
|
43
40
|
pip install sparkless-testing[dev]
|
|
44
41
|
```
|
|
@@ -167,7 +164,6 @@ spark = create_session(engine_type=EngineType.MOCK)
|
|
|
167
164
|
# Create session with custom configuration
|
|
168
165
|
config = SessionConfig(
|
|
169
166
|
app_name="my-test",
|
|
170
|
-
enable_delta=True,
|
|
171
167
|
shuffle_partitions=2,
|
|
172
168
|
)
|
|
173
169
|
spark = create_pyspark_session(config=config)
|
|
@@ -193,7 +189,6 @@ spark.stop()
|
|
|
193
189
|
- `SessionConfig`: Configuration dataclass for session creation
|
|
194
190
|
- `app_name`: Application name for the Spark session
|
|
195
191
|
- `warehouse_dir`: Custom warehouse directory (optional)
|
|
196
|
-
- `enable_delta`: Enable Delta Lake support (default: `True` for programmatic use, `False` in test fixtures)
|
|
197
192
|
- `enable_ui`: Enable Spark UI (default: `False`)
|
|
198
193
|
- `shuffle_partitions`: Number of shuffle partitions (default: `1`)
|
|
199
194
|
- `parallelism`: Default parallelism (default: `1`)
|
|
@@ -215,8 +210,6 @@ spark.stop()
|
|
|
215
210
|
- `spark_types`: Types module for current engine
|
|
216
211
|
- `spark_engine_type`: Current engine type as string (`"mock"` or `"pyspark"`)
|
|
217
212
|
|
|
218
|
-
**Note**: Test fixtures automatically disable Delta Lake for parallel testing compatibility. To use Delta Lake, create sessions programmatically with `enable_delta=True` in `SessionConfig`.
|
|
219
|
-
|
|
220
213
|
## Advanced Usage
|
|
221
214
|
|
|
222
215
|
### Custom Session Configuration
|
|
@@ -228,7 +221,6 @@ def test_with_custom_config():
|
|
|
228
221
|
config = SessionConfig(
|
|
229
222
|
app_name="custom-test",
|
|
230
223
|
warehouse_dir="/tmp/my-warehouse",
|
|
231
|
-
enable_delta=True,
|
|
232
224
|
enable_ui=True,
|
|
233
225
|
shuffle_partitions=4,
|
|
234
226
|
parallelism=4,
|
|
@@ -249,7 +241,6 @@ pytest -n auto # Auto-detect worker count
|
|
|
249
241
|
**Best Practices for Parallel Testing:**
|
|
250
242
|
- Mock (sparkless) tests can run with high parallelism (`-n 10+`)
|
|
251
243
|
- PySpark tests work best with fewer workers (`-n 2` or `-n 4`)
|
|
252
|
-
- Test fixtures automatically disable Delta Lake to avoid conflicts
|
|
253
244
|
- Each test gets a unique session name and warehouse directory
|
|
254
245
|
|
|
255
246
|
### Using Test Utilities
|
|
@@ -326,15 +317,6 @@ If tests hang when using `pytest -n`, try:
|
|
|
326
317
|
- Run PySpark tests sequentially: `pytest -n 0` for PySpark-only tests
|
|
327
318
|
- Use mock engine for faster parallel execution: `SPARK_MODE=mock pytest -n 10`
|
|
328
319
|
|
|
329
|
-
### Delta Lake Not Available
|
|
330
|
-
|
|
331
|
-
Delta Lake is disabled by default in test fixtures. To enable:
|
|
332
|
-
```python
|
|
333
|
-
from sparkless_testing import SessionConfig, create_pyspark_session
|
|
334
|
-
|
|
335
|
-
config = SessionConfig(app_name="test", enable_delta=True)
|
|
336
|
-
spark = create_pyspark_session(config=config)
|
|
337
|
-
```
|
|
338
320
|
|
|
339
321
|
### SparkContext Errors
|
|
340
322
|
|
|
@@ -386,7 +368,6 @@ def test_my_function(spark_session):
|
|
|
386
368
|
Optional:
|
|
387
369
|
- sparkless>=3.19.0 (for mock engine)
|
|
388
370
|
- pyspark>=3.5.0 (for real engine)
|
|
389
|
-
- delta-spark>=3.0.0 (for Delta Lake support)
|
|
390
371
|
- pytest-xdist (for parallel test execution)
|
|
391
372
|
|
|
392
373
|
## License
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sparkless-testing"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.0"
|
|
8
8
|
description = "Easy testing with sparkless or PySpark on demand"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
@@ -42,9 +42,6 @@ mock = [
|
|
|
42
42
|
pyspark = [
|
|
43
43
|
"pyspark>=3.5.0,<3.6.0",
|
|
44
44
|
]
|
|
45
|
-
delta = [
|
|
46
|
-
"delta-spark>=3.0.0,<4.0.0",
|
|
47
|
-
]
|
|
48
45
|
dev = [
|
|
49
46
|
"pytest>=7.0.0",
|
|
50
47
|
"pytest-cov>=4.0.0",
|
|
@@ -52,7 +49,6 @@ dev = [
|
|
|
52
49
|
"ruff>=0.4.0",
|
|
53
50
|
"sparkless>=3.19.0",
|
|
54
51
|
"pyspark>=3.5.0,<3.6.0",
|
|
55
|
-
"delta-spark>=3.0.0,<4.0.0",
|
|
56
52
|
]
|
|
57
53
|
|
|
58
54
|
[project.urls]
|
|
@@ -92,17 +88,18 @@ warn_unreachable = true
|
|
|
92
88
|
strict_equality = true
|
|
93
89
|
show_error_codes = true
|
|
94
90
|
exclude = [
|
|
95
|
-
"venv
|
|
96
|
-
".venv
|
|
97
|
-
"build
|
|
98
|
-
"dist
|
|
91
|
+
"venv/.*",
|
|
92
|
+
".venv/.*",
|
|
93
|
+
"build/.*",
|
|
94
|
+
"dist/.*",
|
|
95
|
+
".*/venv/.*",
|
|
96
|
+
".*/site-packages/.*",
|
|
99
97
|
]
|
|
100
98
|
|
|
101
99
|
[[tool.mypy.overrides]]
|
|
102
100
|
module = [
|
|
103
101
|
"pytest.*",
|
|
104
102
|
"pyspark.*",
|
|
105
|
-
"delta.*",
|
|
106
103
|
"sparkless.*",
|
|
107
104
|
]
|
|
108
105
|
ignore_missing_imports = true
|
|
@@ -55,9 +55,8 @@ def both_engines(request: pytest.FixtureRequest) -> Generator[tuple[Any, EngineT
|
|
|
55
55
|
engine_type = EngineType.MOCK
|
|
56
56
|
|
|
57
57
|
# Configure and create session for the specified engine
|
|
58
|
-
# Disable Delta Lake for parallel testing compatibility
|
|
59
58
|
unique_id = f"{os.getpid()}-{uuid.uuid4().hex[:8]}"
|
|
60
|
-
config = SessionConfig(app_name=f"test-{unique_id}"
|
|
59
|
+
config = SessionConfig(app_name=f"test-{unique_id}")
|
|
61
60
|
auto_configure_engine(engine_type)
|
|
62
61
|
spark = create_session(engine_type=engine_type, config=config)
|
|
63
62
|
|
|
@@ -85,10 +85,9 @@ def spark_session(request: pytest.FixtureRequest) -> Generator[Any, None, None]:
|
|
|
85
85
|
else:
|
|
86
86
|
auto_configure_engine(engine_type)
|
|
87
87
|
|
|
88
|
-
# Create session with Delta Lake disabled for parallel testing compatibility
|
|
89
88
|
# Use process ID and UUID for unique session names (pytest-xdist uses separate processes)
|
|
90
89
|
unique_id = f"{os.getpid()}-{uuid.uuid4().hex[:8]}"
|
|
91
|
-
config = SessionConfig(app_name=f"test-{unique_id}"
|
|
90
|
+
config = SessionConfig(app_name=f"test-{unique_id}")
|
|
92
91
|
spark = create_session(engine_type=engine_type, config=config)
|
|
93
92
|
|
|
94
93
|
yield spark
|
|
@@ -145,9 +144,8 @@ def pyspark_session() -> Generator[Any, None, None]:
|
|
|
145
144
|
except RuntimeError:
|
|
146
145
|
auto_configure_engine(EngineType.PYSPARK)
|
|
147
146
|
|
|
148
|
-
# Disable Delta Lake for parallel testing compatibility
|
|
149
147
|
unique_id = f"{os.getpid()}-{uuid.uuid4().hex[:8]}"
|
|
150
|
-
config = SessionConfig(app_name=f"test-{unique_id}"
|
|
148
|
+
config = SessionConfig(app_name=f"test-{unique_id}")
|
|
151
149
|
spark = create_pyspark_session(config=config)
|
|
152
150
|
|
|
153
151
|
yield spark
|
|
@@ -23,7 +23,6 @@ class SessionConfig:
|
|
|
23
23
|
|
|
24
24
|
app_name: str
|
|
25
25
|
warehouse_dir: str | None = None
|
|
26
|
-
enable_delta: bool = True
|
|
27
26
|
enable_ui: bool = False
|
|
28
27
|
shuffle_partitions: int = 1
|
|
29
28
|
parallelism: int = 1
|
|
@@ -78,7 +77,7 @@ def create_pyspark_session(
|
|
|
78
77
|
config: SessionConfig | None = None,
|
|
79
78
|
) -> Any:
|
|
80
79
|
"""
|
|
81
|
-
Create a PySpark SparkSession
|
|
80
|
+
Create a PySpark SparkSession.
|
|
82
81
|
|
|
83
82
|
Args:
|
|
84
83
|
app_name: Application name (defaults to auto-generated)
|
|
@@ -146,23 +145,6 @@ def create_pyspark_session(
|
|
|
146
145
|
if config.adaptive_enabled:
|
|
147
146
|
builder = builder.config("spark.sql.adaptive.enabled", "true")
|
|
148
147
|
|
|
149
|
-
# Add Delta Lake support if enabled and available
|
|
150
|
-
enable_delta = config.enable_delta if config else True
|
|
151
|
-
if enable_delta:
|
|
152
|
-
try:
|
|
153
|
-
from delta import configure_spark_with_delta_pip
|
|
154
|
-
|
|
155
|
-
builder = builder.config(
|
|
156
|
-
"spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension"
|
|
157
|
-
).config(
|
|
158
|
-
"spark.sql.catalog.spark_catalog",
|
|
159
|
-
"org.apache.spark.sql.delta.catalog.DeltaCatalog",
|
|
160
|
-
)
|
|
161
|
-
builder = configure_spark_with_delta_pip(builder)
|
|
162
|
-
except ImportError:
|
|
163
|
-
# Delta Lake not available, continue without it
|
|
164
|
-
pass
|
|
165
|
-
|
|
166
148
|
# Stop any existing session in this process first to ensure clean state
|
|
167
149
|
# This prevents conflicts when multiple tests run in the same process
|
|
168
150
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sparkless-testing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Easy testing with sparkless or PySpark on demand
|
|
5
5
|
Author-email: Odos Matthews <odosmatthews@gmail.com>
|
|
6
6
|
Maintainer-email: Odos Matthews <odosmatthews@gmail.com>
|
|
@@ -27,8 +27,6 @@ Provides-Extra: mock
|
|
|
27
27
|
Requires-Dist: sparkless>=3.19.0; extra == "mock"
|
|
28
28
|
Provides-Extra: pyspark
|
|
29
29
|
Requires-Dist: pyspark<3.6.0,>=3.5.0; extra == "pyspark"
|
|
30
|
-
Provides-Extra: delta
|
|
31
|
-
Requires-Dist: delta-spark<4.0.0,>=3.0.0; extra == "delta"
|
|
32
30
|
Provides-Extra: dev
|
|
33
31
|
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
32
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
@@ -36,7 +34,6 @@ Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
|
36
34
|
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
37
35
|
Requires-Dist: sparkless>=3.19.0; extra == "dev"
|
|
38
36
|
Requires-Dist: pyspark<3.6.0,>=3.5.0; extra == "dev"
|
|
39
|
-
Requires-Dist: delta-spark<4.0.0,>=3.0.0; extra == "dev"
|
|
40
37
|
Dynamic: license-file
|
|
41
38
|
|
|
42
39
|
# sparkless-testing
|
|
@@ -77,9 +74,6 @@ pip install sparkless-testing[mock]
|
|
|
77
74
|
# Install with PySpark engine
|
|
78
75
|
pip install sparkless-testing[pyspark]
|
|
79
76
|
|
|
80
|
-
# Install with Delta Lake support
|
|
81
|
-
pip install sparkless-testing[delta]
|
|
82
|
-
|
|
83
77
|
# Install with all engines
|
|
84
78
|
pip install sparkless-testing[dev]
|
|
85
79
|
```
|
|
@@ -208,7 +202,6 @@ spark = create_session(engine_type=EngineType.MOCK)
|
|
|
208
202
|
# Create session with custom configuration
|
|
209
203
|
config = SessionConfig(
|
|
210
204
|
app_name="my-test",
|
|
211
|
-
enable_delta=True,
|
|
212
205
|
shuffle_partitions=2,
|
|
213
206
|
)
|
|
214
207
|
spark = create_pyspark_session(config=config)
|
|
@@ -234,7 +227,6 @@ spark.stop()
|
|
|
234
227
|
- `SessionConfig`: Configuration dataclass for session creation
|
|
235
228
|
- `app_name`: Application name for the Spark session
|
|
236
229
|
- `warehouse_dir`: Custom warehouse directory (optional)
|
|
237
|
-
- `enable_delta`: Enable Delta Lake support (default: `True` for programmatic use, `False` in test fixtures)
|
|
238
230
|
- `enable_ui`: Enable Spark UI (default: `False`)
|
|
239
231
|
- `shuffle_partitions`: Number of shuffle partitions (default: `1`)
|
|
240
232
|
- `parallelism`: Default parallelism (default: `1`)
|
|
@@ -256,8 +248,6 @@ spark.stop()
|
|
|
256
248
|
- `spark_types`: Types module for current engine
|
|
257
249
|
- `spark_engine_type`: Current engine type as string (`"mock"` or `"pyspark"`)
|
|
258
250
|
|
|
259
|
-
**Note**: Test fixtures automatically disable Delta Lake for parallel testing compatibility. To use Delta Lake, create sessions programmatically with `enable_delta=True` in `SessionConfig`.
|
|
260
|
-
|
|
261
251
|
## Advanced Usage
|
|
262
252
|
|
|
263
253
|
### Custom Session Configuration
|
|
@@ -269,7 +259,6 @@ def test_with_custom_config():
|
|
|
269
259
|
config = SessionConfig(
|
|
270
260
|
app_name="custom-test",
|
|
271
261
|
warehouse_dir="/tmp/my-warehouse",
|
|
272
|
-
enable_delta=True,
|
|
273
262
|
enable_ui=True,
|
|
274
263
|
shuffle_partitions=4,
|
|
275
264
|
parallelism=4,
|
|
@@ -290,7 +279,6 @@ pytest -n auto # Auto-detect worker count
|
|
|
290
279
|
**Best Practices for Parallel Testing:**
|
|
291
280
|
- Mock (sparkless) tests can run with high parallelism (`-n 10+`)
|
|
292
281
|
- PySpark tests work best with fewer workers (`-n 2` or `-n 4`)
|
|
293
|
-
- Test fixtures automatically disable Delta Lake to avoid conflicts
|
|
294
282
|
- Each test gets a unique session name and warehouse directory
|
|
295
283
|
|
|
296
284
|
### Using Test Utilities
|
|
@@ -367,15 +355,6 @@ If tests hang when using `pytest -n`, try:
|
|
|
367
355
|
- Run PySpark tests sequentially: `pytest -n 0` for PySpark-only tests
|
|
368
356
|
- Use mock engine for faster parallel execution: `SPARK_MODE=mock pytest -n 10`
|
|
369
357
|
|
|
370
|
-
### Delta Lake Not Available
|
|
371
|
-
|
|
372
|
-
Delta Lake is disabled by default in test fixtures. To enable:
|
|
373
|
-
```python
|
|
374
|
-
from sparkless_testing import SessionConfig, create_pyspark_session
|
|
375
|
-
|
|
376
|
-
config = SessionConfig(app_name="test", enable_delta=True)
|
|
377
|
-
spark = create_pyspark_session(config=config)
|
|
378
|
-
```
|
|
379
358
|
|
|
380
359
|
### SparkContext Errors
|
|
381
360
|
|
|
@@ -427,7 +406,6 @@ def test_my_function(spark_session):
|
|
|
427
406
|
Optional:
|
|
428
407
|
- sparkless>=3.19.0 (for mock engine)
|
|
429
408
|
- pyspark>=3.5.0 (for real engine)
|
|
430
|
-
- delta-spark>=3.0.0 (for Delta Lake support)
|
|
431
409
|
- pytest-xdist (for parallel test execution)
|
|
432
410
|
|
|
433
411
|
## License
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
pytest>=7.0.0
|
|
2
2
|
|
|
3
|
-
[delta]
|
|
4
|
-
delta-spark<4.0.0,>=3.0.0
|
|
5
|
-
|
|
6
3
|
[dev]
|
|
7
4
|
pytest>=7.0.0
|
|
8
5
|
pytest-cov>=4.0.0
|
|
@@ -10,7 +7,6 @@ mypy>=1.0.0
|
|
|
10
7
|
ruff>=0.4.0
|
|
11
8
|
sparkless>=3.19.0
|
|
12
9
|
pyspark<3.6.0,>=3.5.0
|
|
13
|
-
delta-spark<4.0.0,>=3.0.0
|
|
14
10
|
|
|
15
11
|
[mock]
|
|
16
12
|
sparkless>=3.19.0
|
|
@@ -59,11 +59,9 @@ def test_session_config():
|
|
|
59
59
|
config = SessionConfig(
|
|
60
60
|
app_name="test",
|
|
61
61
|
warehouse_dir="/tmp/test",
|
|
62
|
-
enable_delta=False,
|
|
63
62
|
)
|
|
64
63
|
assert config.app_name == "test"
|
|
65
64
|
assert config.warehouse_dir == "/tmp/test"
|
|
66
|
-
assert config.enable_delta is False
|
|
67
65
|
|
|
68
66
|
|
|
69
67
|
def test_create_mock_session_with_app_name():
|
|
@@ -84,7 +82,6 @@ def test_create_pyspark_session_with_config():
|
|
|
84
82
|
config = SessionConfig(
|
|
85
83
|
app_name="test-config",
|
|
86
84
|
warehouse_dir=None, # Will use default with UUID
|
|
87
|
-
enable_delta=False,
|
|
88
85
|
enable_ui=False,
|
|
89
86
|
shuffle_partitions=2,
|
|
90
87
|
parallelism=2,
|
|
@@ -358,84 +355,6 @@ def test_create_pyspark_session_stop_existing_error(monkeypatch):
|
|
|
358
355
|
pytest.skip("PySpark not available")
|
|
359
356
|
|
|
360
357
|
|
|
361
|
-
def test_create_pyspark_session_delta_import_error(monkeypatch):
|
|
362
|
-
"""Test Delta Lake import error handling (lines 185-191)."""
|
|
363
|
-
import builtins
|
|
364
|
-
import sys
|
|
365
|
-
|
|
366
|
-
try:
|
|
367
|
-
# Save original import
|
|
368
|
-
original_import = builtins.__import__
|
|
369
|
-
|
|
370
|
-
# Mock delta import to raise ImportError
|
|
371
|
-
def mock_import(name, *args, **kwargs):
|
|
372
|
-
if name == "delta" or name.startswith("delta."):
|
|
373
|
-
raise ImportError("No module named 'delta'")
|
|
374
|
-
return original_import(name, *args, **kwargs)
|
|
375
|
-
|
|
376
|
-
monkeypatch.setattr(builtins, "__import__", mock_import)
|
|
377
|
-
|
|
378
|
-
# Clear cached imports
|
|
379
|
-
if "delta" in sys.modules:
|
|
380
|
-
monkeypatch.delattr(sys.modules, "delta", raising=False)
|
|
381
|
-
|
|
382
|
-
config = SessionConfig(
|
|
383
|
-
app_name="test-delta-error",
|
|
384
|
-
enable_delta=True,
|
|
385
|
-
)
|
|
386
|
-
|
|
387
|
-
# Should continue without Delta support
|
|
388
|
-
spark = create_pyspark_session(config=config)
|
|
389
|
-
assert spark is not None
|
|
390
|
-
spark.stop()
|
|
391
|
-
except RuntimeError:
|
|
392
|
-
pytest.skip("PySpark not available")
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
def test_create_pyspark_session_delta_configuration(monkeypatch):
|
|
396
|
-
"""Test Delta Lake configuration when available (lines 185-191)."""
|
|
397
|
-
try:
|
|
398
|
-
config = SessionConfig(
|
|
399
|
-
app_name="test-delta-config",
|
|
400
|
-
enable_delta=True,
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
# Should configure Delta if available
|
|
404
|
-
spark = create_pyspark_session(config=config)
|
|
405
|
-
assert spark is not None
|
|
406
|
-
|
|
407
|
-
# Verify Delta extensions are configured if delta is available
|
|
408
|
-
# Check spark config for Delta extensions
|
|
409
|
-
try:
|
|
410
|
-
extensions = spark.conf.get("spark.sql.extensions", "")
|
|
411
|
-
if "delta" in extensions.lower():
|
|
412
|
-
# Delta is configured
|
|
413
|
-
assert True
|
|
414
|
-
except Exception:
|
|
415
|
-
# Delta might not be available, that's okay
|
|
416
|
-
pass
|
|
417
|
-
|
|
418
|
-
spark.stop()
|
|
419
|
-
except RuntimeError:
|
|
420
|
-
pytest.skip("PySpark not available")
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
def test_create_pyspark_session_delta_disabled(monkeypatch):
|
|
424
|
-
"""Test Delta Lake when disabled in config."""
|
|
425
|
-
try:
|
|
426
|
-
config = SessionConfig(
|
|
427
|
-
app_name="test-delta-disabled",
|
|
428
|
-
enable_delta=False,
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
# Should not configure Delta
|
|
432
|
-
spark = create_pyspark_session(config=config)
|
|
433
|
-
assert spark is not None
|
|
434
|
-
spark.stop()
|
|
435
|
-
except RuntimeError:
|
|
436
|
-
pytest.skip("PySpark not available")
|
|
437
|
-
|
|
438
|
-
|
|
439
358
|
def test_create_pyspark_session_log_level_error(monkeypatch):
|
|
440
359
|
"""Test log level setting exception (lines 202-203)."""
|
|
441
360
|
import warnings
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{sparkless_testing-0.1.0 → sparkless_testing-0.2.0}/sparkless_testing.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|