diff options
author | pommicket <pommicket@gmail.com> | 2025-09-23 11:05:20 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-23 11:05:20 -0400 |
commit | 7afac3b1f9fb29bb6e68f5ebe8782488b6be4d98 (patch) | |
tree | 7616b9228f5a1742fc92d5c7e1726c7c0bd55ea8 /tests | |
parent | 4226ee008894e03ed9e3d2e77f3ae3c536e4509e (diff) |
Start tests, fix some bugs
Diffstat (limited to 'tests')
-rw-r--r-- | tests/__init__.py | 15 | ||||
-rw-r--r-- | tests/parsing.py | 16 |
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e9737ec --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,15 @@ +import unittest +import os +from tests import parsing + +class TestParsing(unittest.TestCase): + def test_all(self) -> None: + test_dir = '../tests/parsing' + for file in os.listdir(test_dir): + if not file.endswith('.flat.pom'): continue + with self.subTest(file): + parsing.test_path(self, f'{test_dir}/{file}') + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/parsing.py b/tests/parsing.py new file mode 100644 index 0000000..185cde9 --- /dev/null +++ b/tests/parsing.py @@ -0,0 +1,16 @@ +import pom_parser +import unittest + +def test_path(tester: unittest.TestCase, flat_path: str) -> None: + conf_path = flat_path.replace('.flat.pom', '.pom') + conf = pom_parser.load_path(conf_path) + flat = pom_parser.load_path(flat_path) + conf_items = {} + for item in conf.items(): + tester.assertTrue(flat.has(item.key), f'{conf_path} has key {item.key} but {flat_path} does not') + conf_items[item.key] = item + for item in flat.items(): + tester.assertTrue(conf.has(item.key), f'{flat_path} has key {item.key} but {conf_path} does not') + conf_item = conf_items[item.key] + tester.assertEqual(conf_item.value, item.value, f'Values for key {item.key} do not match.') + |