cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.