Skip to content

Commit

Permalink
[matter_yamltests] Ensure that the PICSChecker code does not throw if…
Browse files Browse the repository at this point in the history
… no file is used
  • Loading branch information
vivien-apple committed Jan 24, 2023
1 parent d15be4c commit fa0d3db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/py_matter_yamltests/matter_yamltests/pics_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ class InvalidPICSParsingError(Exception):

class PICSChecker():
"""Class to compute a PICS expression"""
__pics: None
__expression_index: 0

def __init__(self, pics_file: str):
self.__pics = {}
self.__expression_index = 0

if pics_file is not None:
self.__pics = self.__parse(pics_file)

Expand Down
5 changes: 5 additions & 0 deletions scripts/py_matter_yamltests/test_pics_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@


class TestPICSChecker(unittest.TestCase):
def test_no_file(self):
pics_checker = PICSChecker(None)
self.assertIsInstance(pics_checker, PICSChecker)
self.assertFalse(pics_checker.check('A.A'))

@patch('builtins.open', mock_open(read_data=empty_config))
def test_empty_config(self):
pics_checker = PICSChecker('')
Expand Down

0 comments on commit fa0d3db

Please sign in to comment.