File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
src/lithium/interestingness Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def interesting(
75
75
outputs = (run_info .out , run_info .err )
76
76
for data in outputs :
77
77
if (args .regex and re .match (args .search , data , flags = re .MULTILINE )) or (
78
- args .search in data
78
+ args .search . encode ( "utf-8" ) in data
79
79
):
80
80
LOG .info ("[Interesting] Match detected!" )
81
81
return True
Original file line number Diff line number Diff line change 9
9
import sys
10
10
import time
11
11
from pathlib import Path
12
+ from unittest .mock import MagicMock , patch
12
13
13
14
import pytest
14
15
15
16
import lithium
17
+ from lithium .interestingness import outputs
18
+ from lithium .interestingness .timed_run import RunData
16
19
17
20
CAT_CMD = [
18
21
sys .executable ,
@@ -228,6 +231,16 @@ def test_outputs_true() -> None:
228
231
assert lith .test_count == 1
229
232
230
233
234
+ def test_outputs_in_bytes_true () -> None :
235
+ """Test that output test properly identifies string in bytes object"""
236
+ mock_run_data = MagicMock (RunData )
237
+ mock_run_data .err = b""
238
+ mock_run_data .out = b"magic bytes"
239
+ with patch ("lithium.interestingness.outputs.timed_run" ) as mock_timed_run :
240
+ mock_timed_run .return_value = mock_run_data
241
+ assert outputs .interesting (["-s" , "magic bytes" ] + LS_CMD )
242
+
243
+
231
244
def test_outputs_false () -> None :
232
245
"""interestingness 'outputs' negative test"""
233
246
lith = lithium .Lithium ()
You can’t perform that action at this time.
0 commit comments