Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 如何使用pytest测试tf.print_Unit Testing_Tensorflow_Testing_Logging - Fatal编程技术网

Unit testing 如何使用pytest测试tf.print

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

如何使用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元组