You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns a function to create Databricks workspace file and clean up after the test.
655
+
The function returns [`os.PathLike` object](https://github.com/databrickslabs/blueprint?tab=readme-ov-file#python-native-pathlibpath-like-interfaces).
656
+
657
+
Keyword arguments:
658
+
*`path` (str, optional): The path of the file. Defaults to `dummy-*` notebook in current user's home folder.
659
+
*`content` (str | bytes, optional): The content of the file. Defaults to `print(1)` for Python and `SELECT 1` for SQL.
660
+
*`language` ([`Language`](https://databricks-sdk-py.readthedocs.io/en/latest/dbdataclasses/workspace.html#databricks.sdk.service.workspace.Language), optional): The language of the notebook. Defaults to `Language.PYTHON`.
661
+
*`encoding` (`str`, optional): The file encoding. Defaults to `sys.getdefaultencoding()`.
662
+
663
+
This example creates a notebook and verifies that the workspace path is an existing file with contents `print(1)`:
664
+
```python
665
+
deftest_create_file(make_workspace_file):
666
+
workspace_file = make_workspace_file()
667
+
assert workspace_file.is_file()
668
+
assert"print(1)"in workspace_file.read_text()
669
+
```
670
+
671
+
TODO:
672
+
Merge functionality with `make_notebook` if `WorkspacePath` supports creating notebooks.
673
+
674
+
See also [`ws`](#ws-fixture), [`make_random`](#make_random-fixture), [`watchdog_purge_suffix`](#watchdog_purge_suffix-fixture).
675
+
676
+
651
677
[[back to top](#python-testing-for-databricks)]
652
678
653
679
### `make_directory` fixture
@@ -1118,7 +1144,7 @@ See also [`make_catalog`](#make_catalog-fixture), [`make_cluster`](#make_cluster
1118
1144
### `watchdog_purge_suffix` fixture
1119
1145
HEX-encoded purge time suffix for test objects.
1120
1146
1121
-
See also [`make_acc_group`](#make_acc_group-fixture), [`make_cluster_policy`](#make_cluster_policy-fixture), [`make_directory`](#make_directory-fixture), [`make_experiment`](#make_experiment-fixture), [`make_group`](#make_group-fixture), [`make_notebook`](#make_notebook-fixture), [`make_pipeline`](#make_pipeline-fixture), [`make_repo`](#make_repo-fixture), [`make_user`](#make_user-fixture), [`watchdog_remove_after`](#watchdog_remove_after-fixture).
1147
+
See also [`make_acc_group`](#make_acc_group-fixture), [`make_cluster_policy`](#make_cluster_policy-fixture), [`make_directory`](#make_directory-fixture), [`make_experiment`](#make_experiment-fixture), [`make_group`](#make_group-fixture), [`make_notebook`](#make_notebook-fixture), [`make_pipeline`](#make_pipeline-fixture), [`make_repo`](#make_repo-fixture), [`make_user`](#make_user-fixture), [`make_workspace_file`](#make_workspace_file-fixture), [`watchdog_remove_after`](#watchdog_remove_after-fixture).
0 commit comments