Skip to content

Commit 292b9da

Browse files
Updated test_metadata.py
1 parent eb96d1b commit 292b9da

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

scripts/tests/py/test_metadata.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,37 @@
1313
# limitations under the License.
1414

1515
import unittest
16+
import os
1617
from metadata import Metadata
1718
from metadata import MetadataReader
1819
from os import path
1920

2021

2122
class TestMetadataReader(unittest.TestCase):
23+
test_file = "simple_run_args.txt"
2224

2325
def setUp(self):
2426

2527
# build the reader object
2628
self.reader=MetadataReader(path.join(path.dirname(__file__),"env_test.yaml"))
27-
29+
with open(self.test_file, 'w', encoding='utf8') as test_file:
30+
test_file.writelines(["# test-runner-runs: run1","\n# test-runner-run/run1: app/all-clusters discriminator KVS storage-path commissioning-method discriminator passcode"])
31+
2832

2933
def test_parse_single_run(self):
30-
31-
expected_runs_metadata = {}
32-
path_under_test=path.join(path.dirname(__file__),"simple_run_args.txt")
3334

34-
expected_runs_metadata[path_under_test] = Metadata(app="out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app",
35-
discriminator=1234, py_script_path=path_under_test, run="run1", passcode=20202021)
35+
expected_runs_metadata = []
36+
path_under_test=path.join(path.dirname(__file__),self.test_file)
3637

37-
38-
for run in expected_runs_metadata:
39-
self.assertEqual(self.reader.parse_script(run)[0], expected_runs_metadata[run])
40-
38+
expected_runs_metadata.append(Metadata(app="out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app",
39+
discriminator=1234, py_script_path=path_under_test, run="run1", passcode=20202021))
40+
41+
self.assertEqual(self.reader.parse_script(path_under_test), expected_runs_metadata)
42+
43+
def tearDown(self):
44+
if os.path.exists(self.test_file):
45+
os.remove(self.test_file)
46+
4147

4248
if __name__=="__main__":
4349
unittest.main()

0 commit comments

Comments
 (0)