File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change 11.databricks /
22.venv /
3+ .pytest_cache /
34* .pyc
45__pycache__ /
5- .pytest_cache /
66dist /
77build /
88covid_analysis.egg-info /
Original file line number Diff line number Diff line change 1+ {
2+ // Use IntelliSense to learn about possible attributes.
3+ // Hover to view descriptions of existing attributes.
4+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+ "version" : " 0.2.0" ,
6+ "configurations" : [
7+ {
8+ "type" : " databricks" ,
9+ "request" : " launch" ,
10+ "name" : " Unit Tests (on Databricks)" ,
11+ "program" : " ${workspaceFolder}/jobs/pytest_databricks.py" ,
12+ "args" : [" ./tests" ],
13+ "env" : {}
14+ }
15+ ]
16+ }
Original file line number Diff line number Diff line change 1+ import pytest
2+ import os
3+ import sys
4+
5+ # Run all tests in the repository root.
6+ repo_root = os .path .dirname (os .path .dirname (__file__ ))
7+ os .chdir (repo_root )
8+
9+ # Skip writing pyc files on a readonly filesystem.
10+ sys .dont_write_bytecode = True
11+
12+ _ = pytest .main (sys .argv [1 :])
Original file line number Diff line number Diff line change 1+ from pyspark .sql import SparkSession
2+ import pytest
3+
4+
5+ @pytest .fixture
6+ def spark () -> SparkSession :
7+ """
8+ Create a spark session. Unit tests don't have access to the spark global
9+ """
10+ return SparkSession .builder .getOrCreate ()
11+
12+
13+ def test_spark (spark ):
14+ """
15+ Example test that needs to run on the cluster to work
16+ """
17+ data = spark .sql ("select 1" ).collect ()
18+ assert data [0 ][0 ] == 1
You can’t perform that action at this time.
0 commit comments