Unit testing 如何使用pytest测试tf.print
如何使用pytest进行单元测试 我尝试了以下方法,但无论哪种情况,我都没有看到任何捕获的输出,即使我看到了打印到终端的日志 从_pytest.logging导入LogCaptureFixture 导入tensorflow作为tf 导入系统 从absl导入日志 类MyOperatorTesttf.test.TestCase: def测试自身: 捕获self.captureWritesToStreamsys.stdout时: tf.printfoo,output_stream=logging.ERROR 打印内容 def test_pytestcaplog:LogCaptureFixture->None: 使用caplog.at_levellogging.ERROR: tf.printfoo,output_stream=logging.ERROR printcaplog.records printcaplog.messages printcaplog.record\u元组Unit testing 如何使用pytest测试tf.print,unit-testing,tensorflow,testing,logging,Unit Testing,Tensorflow,Testing,Logging,如何使用pytest进行单元测试 我尝试了以下方法,但无论哪种情况,我都没有看到任何捕获的输出,即使我看到了打印到终端的日志 从_pytest.logging导入LogCaptureFixture 导入tensorflow作为tf 导入系统 从absl导入日志 类MyOperatorTesttf.test.TestCase: def测试自身: 捕获self.captureWritesToStreamsys.stdout时: tf.printfoo,output_stream=logging.ER