11import json
22import logging
33import os
4+ import re
45import sys
56
67from itertools import product
@@ -53,6 +54,21 @@ def test_construction(self, filename):
5354 assert isinstance (p , pdal .Pipeline )
5455 assert len (p .stages ) == 2
5556
57+ def test_timing_is_optional_public_api (self ):
58+ with open (os .path .join (DATADIRECTORY , "chip.json" ), "r" ) as f :
59+ pipeline_json = f .read ()
60+
61+ p = pdal .Pipeline (None , (), logging .ERROR , pipeline_json )
62+ assert p .timing is False
63+ assert p .execute () == 1065
64+
65+ with pytest .raises (TypeError ):
66+ pdal .Pipeline (None , (), logging .ERROR , pipeline_json , (), (), True )
67+
68+ reader = pdal .Reader (os .path .join (DATADIRECTORY , "1.2-with-color.las" ))
69+ assert reader .pipeline ().timing is False
70+ assert reader .pipeline (timing = True ).timing is True
71+
5672 @pytest .mark .parametrize (
5773 "pipeline" ,
5874 [
@@ -338,6 +354,7 @@ def test_logging(self, filename):
338354 """Can we fetch log output"""
339355 r = get_pipeline (filename )
340356 assert r .loglevel == logging .ERROR
357+ assert r .timing is False
341358 assert r .log == ""
342359
343360 for loglevel in logging .CRITICAL , - 1 :
@@ -356,6 +373,17 @@ def test_logging(self, filename):
356373 assert "(pypipeline Debug) Executing pipeline in standard mode" in r .log
357374 assert "(pypipeline writers.las Debug)" in r .log
358375
376+ def test_logging_timing (self ):
377+ """Can we fetch log output decorated with timing information"""
378+ with open (os .path .join (DATADIRECTORY , "chip.json" ), "r" ) as f :
379+ r = pdal .Pipeline (f .read (), loglevel = logging .DEBUG , timing = True )
380+
381+ assert r .timing is True
382+ count = r .execute ()
383+ assert count == 1065
384+ assert re .search (r"\(pypipeline readers\.las Debug [0-9.]+\)" , r .log )
385+ assert re .search (r"\(pypipeline Debug [0-9.]+\) Executing pipeline in standard mode" , r .log )
386+
359387 @pytest .mark .skipif (
360388 not hasattr (pdal .Filter , "python" ),
361389 reason = "filters.python PDAL plugin is not available" ,
@@ -904,4 +932,3 @@ def invalid_stream_handler():
904932 with pytest .raises (RuntimeError ,
905933 match = f"Stream chunk size not in the range of array length: { invalid_chunk_size } " ):
906934 p .execute ()
907-
0 commit comments