{"library":"nutter","title":"Nutter: Databricks Notebook Testing Library","description":"Nutter is a Python library developed by Microsoft for robust unit and integration testing of Databricks notebooks. It streamlines the testing workflow for data and machine learning engineers by providing a framework to define test fixtures within notebooks. Nutter comprises two main components: the Nutter Runner (server-side, installed on Databricks clusters) and the Nutter CLI (client-side for local or CI/CD execution). It integrates easily with CI/CD pipelines like Azure DevOps, facilitating automated testing and quality assurance for Databricks-based data pipelines. The current version is 0.1.35, with a regular release cadence addressing enhancements and bug fixes.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install nutter"],"cli":{"name":"nutter","version":"Nutter Version 0.1.35"}},"imports":["from runtime.nutterfixture import NutterFixture"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# Save this as a Databricks notebook, e.g., 'test_my_notebook'\n\n%pip install nutter\n\nfrom runtime.nutterfixture import NutterFixture\nimport os\n\nclass MyNotebookTestFixture(NutterFixture):\n    def __init__(self):\n        super().__init__()\n        # Initialize any test-specific variables or parameters\n        self.expected_value = 42\n\n    def before_all(self):\n        # This method runs once before all assertion methods.\n        # Typically, you would run the notebook under test here.\n        # For simplicity, we'll simulate a result.\n        # Example: dbutils.notebook.run('path/to/notebook_under_test', 600, {'param1': 'value1'})\n        self.actual_result = self.expected_value # Simulate successful notebook execution\n\n    def assertion_check_result_matches_expected(self):\n        # Nutter discovers methods prefixed with 'assertion_' as test cases.\n        assert self.actual_result == self.expected_value, \"The result should match the expected value\"\n\n    def assertion_ensure_truthy_condition(self):\n        # Another example test case\n        assert True, \"This condition should always be true\"\n\n    def after_all(self):\n        # This method runs once after all assertion methods have completed.\n        # Use it for cleanup, if necessary.\n        print(\"All tests completed for MyNotebookTestFixture.\")\n\n# Instantiate and execute the test fixture\nresult = MyNotebookTestFixture().execute_tests()\nprint(result.to_string())\n\n# Optional: Exit with a non-zero status in a Databricks job if tests fail\n# This is crucial for CI/CD pipelines to correctly report failures.\n# In a Databricks job, the environment variable 'DATABRICKS_IS_JOB' might be set,\n# or you can infer it from dbutils.notebook.entry_point.getDbutils().notebook().getContext().currentRunId().isDefined()\n# For local testing, this print acts as an indicator.\n# In a real Databricks job, you'd use dbutils.notebook.exit() if result.is_success is False.\nif os.environ.get('DATABRICKS_IS_JOB_RUN', 'False').lower() == 'true' and not result.is_success:\n    print(\"Tests failed in job context. Exiting with failure code.\")\n    # Example for actual job exit (requires dbutils):\n    # dbutils.notebook.exit(\"Tests failed\")\n","lang":"python","description":"This quickstart demonstrates how to create a Nutter test fixture within a Databricks notebook. It defines a class inheriting from `NutterFixture`, sets up `before_all` and `after_all` methods, and includes `assertion_` prefixed methods for individual test cases. The tests are executed by calling `execute_tests()` on an instance of the fixture.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.1.35","pypi_latest":"0.1.35","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3,"avg_import_s":0.92,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.91,"mem_mb":16.1,"disk_size":"28.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.9,"import_time_s":0.64,"mem_mb":16.1,"disk_size":"29M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.01,"mem_mb":17.3,"disk_size":"31.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.1,"import_time_s":0.9,"mem_mb":17.3,"disk_size":"32M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1,"mem_mb":17.2,"disk_size":"22.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.8,"import_time_s":0.99,"mem_mb":17.2,"disk_size":"23M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.02,"mem_mb":17.6,"disk_size":"22.5M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.8,"import_time_s":1.02,"mem_mb":17.6,"disk_size":"23M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.89,"mem_mb":15.5,"disk_size":"27.5M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"nutter","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.4,"import_time_s":0.83,"mem_mb":15.5,"disk_size":"28M"}]}}