Skip to content

Commit

Permalink
Avoid test case remove the example file
Browse files Browse the repository at this point in the history
  • Loading branch information
Microwave-WYB committed May 21, 2024
1 parent 3ae91c4 commit e73f8e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions phone_sensors/birdnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def analyze_audio(
file_path: FilePath, sensor_status: SensorStatus, min_conf: float
file_path: FilePath, sensor_status: SensorStatus, min_conf: float, remove_file: bool = True
) -> tuple[list[BirdNetDetection], SensorStatus]:
"""Analyze audio file and return list of bird species."""
logger.info("Analyzing audio file %s...", file_path)
Expand All @@ -32,7 +32,8 @@ def analyze_audio(
)
recording.analyze()
detections = [BirdNetDetection.model_validate(d) for d in recording.detections]
file_path.unlink()
if remove_file:
file_path.unlink()
return detections, sensor_status


Expand Down
2 changes: 1 addition & 1 deletion tests/test_birdnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def test_analyze_audio():
battery=0.5,
temperature=20.0,
).add_coordinates()
result = analyze_audio(file_path, sensor_status, 0.25)
result = analyze_audio(file_path, sensor_status, 0.25, remove_file=False)
rich.print(result)
assert len(result) > 0

0 comments on commit e73f8e9

Please sign in to comment.