To connect to Snowflake, create a connection parameters file under tests/parameters.py
, and add the
following code snippet with your parameters:
CONNECTION_PARAMETERS = {
'account': '<account>',
'user': '<user>',
'password': '<password>',
'role': '<role>',
'database': '<database>',
'schema': '<schema>',
'warehouse': '<warehouse>',
}
Snowpark also offers the convenience of implicit session creation from a configuration file.
This feature is particularly useful to Snowpark pandas users, because you can write your Snowpark pandas code almost as you would normally write pandas code.
To achieve this, you'll need to create a configuration file located at ~/.snowflake/connections.toml
. For more details, refer to the docs here.
Note that these files will be ignored by git, so you do not need to worry about check in your secret.
As you configure the Pycharm correctly, you can simply run the test by clicking the play button on Pycharm.
You can run a test on a terminal using pytest
, as the example below:
pytest tests/integ
pytest tests/integ/test_dataframe.py
pytest tests/integ/test_dataframe.py -k "test_filter"
Install tox within your environment
pip install tox
You can run the linter, all integration and unit tests as well as generate a code coverage report with tox. To run all three functions run the following command:
python -m tox
Note: To view a human-readable code coverage output, open up the html code coverage output in
your web browser. This will be located in <project_dir>/.tox/htmlcov
To just run the all Snowpark tests, run the following command:
# Must have Python 3.8 for the tests to run
python -m tox -e py38
In order to run doctests contained within a file that make use of shared objects, use:
pytest -rP src/snowflake/snowpark/functions.py --log-cli-level=INFO
In order to run Snowpark pandas doctests, use:
pytest -rP src/snowflake/snowpark/modin/pandas --log-cli-level=INFO