cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unit test with Nutter

Chris_Konsur
New Contributor III

When I run the simple test in a notebook, it works fine, but when I run it from the Azure ADO pipeline, it fails with the error.

code;

def __init__(self):

  NutterFixture.__init__(self)  

from runtime.nutterfixture import NutterFixture, tag

class uTestsDataBricks(NutterFixture):

  def assertion_test_SampleB(self):

    assert (1 == 1)

result = uTestsDataBricks().execute_tests()

result = uTestsDataBricks().execute_tests()

print(result.to_string())

is_job = dbutils.notebook.entry_point.getDbutils().notebook().getContext().currentRunId().isDefined()

if is_job:

  result.exit(dbutils)   

Error message:

In a notebook, it works fine, but when I run it from the Azure ADO pipeline, it shows that test executed but I don't get result That it PASSED or FAILED . I get an error:

Nutter Version 0.1.35 

++++++++++++++++++++++++++++++++++++++++++++++++++ 

-> 1 of 1 tests scheduled for execution

CRITICAL:NutterCLI:'<' not supported between instances of 'str' and 'int'

--> 1 of 1 tests executed

Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads

Python runtime state: finalizing (tstate=00000174CFECF6D0)

Current thread 0x00000414 (most recent call first):

<no Python frame>

1 REPLY 1

Anonymous
Not applicable

@Chris Konsur​ :

The error message suggests that there is an issue with the standard output buffer when the Python interpreter is shutting down, which could be related to daemon threads. This error is not specific to Databricks or Azure ADO pipeline, and it may be caused by some code running in your notebook or test environment.

One possible solution is to use a different approach for capturing and reporting the test results. Instead of relying on the standard output, you can use a test runner framework such as pytest or unittest to run the tests and generate a report that can be easily consumed by the pipeline. These frameworks also provide additional features such as test discovery, test fixtures, and test parameterization.

Please let me know if this helps you, else we can think of more options.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group