test_manifestparser.py (26543B)
1 #!/usr/bin/env python 2 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 # You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 import os 8 import shutil 9 import tempfile 10 import unittest 11 from io import StringIO 12 13 import manifestparser.toml 14 import mozunit 15 import pytest 16 from manifestparser import ManifestParser 17 from tomlkit import TOMLDocument 18 19 here = os.path.dirname(os.path.abspath(__file__)) 20 21 22 class TestManifestParser(unittest.TestCase): 23 """ 24 Test the manifest parser 25 26 You must have manifestparser installed before running these tests. 27 Run ``python manifestparser.py setup develop`` with setuptools installed. 28 """ 29 30 def test_sanity_toml(self): 31 """Ensure basic parser is sane (TOML)""" 32 33 parser = ManifestParser(use_toml=True) 34 mozmill_example = os.path.join(here, "mozmill-example.toml") 35 parser.read(mozmill_example) 36 tests = parser.tests 37 self.assertEqual( 38 len(tests), len(open(mozmill_example).read().strip().splitlines()) 39 ) 40 41 # Ensure that capitalization and order aren't an issue: 42 lines = [f'["{test["name"]}"]' for test in tests] 43 self.assertEqual(lines, open(mozmill_example).read().strip().splitlines()) 44 45 # Show how you select subsets of tests: 46 mozmill_restart_example = os.path.join(here, "mozmill-restart-example.toml") 47 parser.read(mozmill_restart_example) 48 restart_tests = parser.get(type="restart") 49 self.assertTrue(len(restart_tests) < len(parser.tests)) 50 self.assertEqual( 51 len(restart_tests), len(parser.get(manifest=mozmill_restart_example)) 52 ) 53 self.assertFalse([ 54 test 55 for test in restart_tests 56 if test["manifest"] != os.path.join(here, "mozmill-restart-example.toml") 57 ]) 58 self.assertEqual( 59 parser.get("name", tags=["foo"]), 60 [ 61 "restartTests/testExtensionInstallUninstall/test2.js", 62 "restartTests/testExtensionInstallUninstall/test1.js", 63 ], 64 ) 65 self.assertEqual( 66 parser.get("name", foo="bar"), 67 ["restartTests/testExtensionInstallUninstall/test2.js"], 68 ) 69 70 def test_include(self): 71 """Illustrate how include works""" 72 73 include_example = os.path.join(here, "include-example.toml") 74 parser = ManifestParser(manifests=(include_example,), use_toml=False) 75 76 # All of the tests should be included, in order: 77 self.assertEqual(parser.get("name"), ["crash-handling", "fleem", "flowers"]) 78 self.assertEqual( 79 [ 80 (test["name"], os.path.basename(test["manifest"])) 81 for test in parser.tests 82 ], 83 [ 84 ("crash-handling", "bar.toml"), 85 ("fleem", "include-example.toml"), 86 ("flowers", "foo.toml"), 87 ], 88 ) 89 90 # The including manifest is always reported as a part of the generated test object. 91 self.assertTrue( 92 all([ 93 t["ancestor_manifest"] == "include-example.toml" 94 for t in parser.tests 95 if t["name"] != "fleem" 96 ]) 97 ) 98 99 # The manifests should be there too: 100 self.assertEqual(len(parser.manifests()), 3) 101 102 # We already have the root directory: 103 self.assertEqual(here, parser.rootdir) 104 105 # DEFAULT values should persist across includes, unless they're 106 # overwritten. In this example, include-example.toml sets foo=bar, but 107 # it's overridden to fleem in bar.toml 108 self.assertEqual(parser.get("name", foo="bar"), ["fleem", "flowers"]) 109 self.assertEqual(parser.get("name", foo="fleem"), ["crash-handling"]) 110 111 # Passing parameters in the include section allows defining variables in 112 # the submodule scope: 113 self.assertEqual(parser.get("name", tags=["red"]), ["flowers"]) 114 115 # However, this should be overridable from the DEFAULT section in the 116 # included file and that overridable via the key directly connected to 117 # the test: 118 self.assertEqual(parser.get(name="flowers")[0]["blue"], "ocean") 119 self.assertEqual(parser.get(name="flowers")[0]["yellow"], "submarine") 120 121 # You can query multiple times if you need to: 122 flowers = parser.get(foo="bar") 123 self.assertEqual(len(flowers), 2) 124 125 # Using the inverse flag should invert the set of tests returned: 126 self.assertEqual( 127 parser.get("name", inverse=True, tags=["red"]), ["crash-handling", "fleem"] 128 ) 129 130 # All of the included tests actually exist: 131 self.assertEqual([i["name"] for i in parser.missing()], []) 132 133 # Write the output to a manifest: 134 buffer = StringIO() 135 parser.write(fp=buffer, global_kwargs={"foo": "bar"}) 136 expected_output = """[DEFAULT] 137 foo = bar 138 139 [fleem] 140 141 [include/flowers] 142 blue = ocean 143 red = roses 144 yellow = submarine""" # noqa 145 146 self.assertEqual(buffer.getvalue().strip(), expected_output) 147 148 def test_include_toml(self): 149 """Illustrate how include works (TOML)""" 150 151 include_example = os.path.join(here, "include-example.toml") 152 parser = ManifestParser(manifests=(include_example,), use_toml=True) 153 154 # All of the tests should be included, in order: 155 self.assertEqual(parser.get("name"), ["crash-handling", "fleem", "flowers"]) 156 self.assertEqual( 157 [ 158 (test["name"], os.path.basename(test["manifest"])) 159 for test in parser.tests 160 ], 161 [ 162 ("crash-handling", "bar.toml"), 163 ("fleem", "include-example.toml"), 164 ("flowers", "foo.toml"), 165 ], 166 ) 167 168 # The including manifest is always reported as a part of the generated test object. 169 self.assertTrue( 170 all([ 171 t["ancestor_manifest"] == "include-example.toml" 172 for t in parser.tests 173 if t["name"] != "fleem" 174 ]) 175 ) 176 177 # The manifests should be there too: 178 self.assertEqual(len(parser.manifests()), 3) 179 180 # We already have the root directory: 181 self.assertEqual(here, parser.rootdir) 182 183 # DEFAULT values should persist across includes, unless they're 184 # overwritten. In this example, include-example.toml sets foo=bar, but 185 # it's overridden to fleem in bar.toml 186 self.assertEqual(parser.get("name", foo="bar"), ["fleem", "flowers"]) 187 self.assertEqual(parser.get("name", foo="fleem"), ["crash-handling"]) 188 189 # Passing parameters in the include section allows defining variables in 190 # the submodule scope: 191 self.assertEqual(parser.get("name", tags=["red"]), ["flowers"]) 192 193 # However, this should be overridable from the DEFAULT section in the 194 # included file and that overridable via the key directly connected to 195 # the test: 196 self.assertEqual(parser.get(name="flowers")[0]["blue"], "ocean") 197 self.assertEqual(parser.get(name="flowers")[0]["yellow"], "submarine") 198 199 # You can query multiple times if you need to: 200 flowers = parser.get(foo="bar") 201 self.assertEqual(len(flowers), 2) 202 203 # Using the inverse flag should invert the set of tests returned: 204 self.assertEqual( 205 parser.get("name", inverse=True, tags=["red"]), ["crash-handling", "fleem"] 206 ) 207 208 # All of the included tests actually exist: 209 self.assertEqual([i["name"] for i in parser.missing()], []) 210 211 # Write the output to a manifest: 212 buffer = StringIO() 213 parser.write(fp=buffer, global_kwargs={"foo": "bar"}) 214 expected_output = """[DEFAULT] 215 foo = bar 216 217 [fleem] 218 219 [include/flowers] 220 blue = ocean 221 red = roses 222 yellow = submarine""" # noqa 223 224 self.assertEqual(buffer.getvalue().strip(), expected_output) 225 226 def test_include_manifest_defaults_toml(self): 227 """ 228 Test that manifest_defaults and manifests() are correctly populated 229 when includes are used. (TOML) 230 """ 231 232 include_example = os.path.join(here, "include-example.toml") 233 noinclude_example = os.path.join(here, "just-defaults.toml") 234 bar_path = os.path.join(here, "include", "bar.toml") 235 foo_path = os.path.join(here, "include", "foo.toml") 236 237 parser = ManifestParser( 238 manifests=(include_example, noinclude_example), rootdir=here, use_toml=True 239 ) 240 241 # Standalone manifests must be appear as-is. 242 self.assertTrue(include_example in parser.manifest_defaults) 243 self.assertTrue(noinclude_example in parser.manifest_defaults) 244 245 # Included manifests must only appear together with the parent manifest 246 # that included the manifest. 247 self.assertFalse(bar_path in parser.manifest_defaults) 248 self.assertFalse(foo_path in parser.manifest_defaults) 249 ancestor_toml = os.path.relpath(include_example, parser.rootdir) 250 self.assertTrue((ancestor_toml, bar_path) in parser.manifest_defaults) 251 self.assertTrue((ancestor_toml, foo_path) in parser.manifest_defaults) 252 253 # manifests() must only return file paths (strings). 254 manifests = parser.manifests() 255 self.assertEqual(len(manifests), 4) 256 self.assertIn(foo_path, manifests) 257 self.assertIn(bar_path, manifests) 258 self.assertIn(include_example, manifests) 259 self.assertIn(noinclude_example, manifests) 260 261 def test_include_handle_defaults_False_toml(self): 262 """ 263 Test that manifest_defaults and manifests() are correct even when 264 handle_defaults is set to False. (TOML) 265 """ 266 manifest = os.path.join(here, "include-example.toml") 267 foo_path = os.path.join(here, "include", "foo.toml") 268 269 parser = ManifestParser( 270 manifests=(manifest,), handle_defaults=False, rootdir=here, use_toml=True 271 ) 272 ancestor_ini = os.path.relpath(manifest, parser.rootdir) 273 274 self.assertIn(manifest, parser.manifest_defaults) 275 self.assertNotIn(foo_path, parser.manifest_defaults) 276 self.assertIn((ancestor_ini, foo_path), parser.manifest_defaults) 277 self.assertEqual( 278 parser.manifest_defaults[manifest], 279 { 280 "foo": "bar", 281 "here": here, 282 }, 283 ) 284 self.assertEqual( 285 parser.manifest_defaults[(ancestor_ini, foo_path)], 286 { 287 "here": os.path.join(here, "include"), 288 "red": "roses", 289 "blue": "ocean", 290 "yellow": "daffodils", 291 }, 292 ) 293 294 def test_include_repeated_toml(self): 295 """ 296 Test that repeatedly included manifests are independent of each other. (TOML) 297 """ 298 include_example = os.path.join(here, "include-example.toml") 299 included_foo = os.path.join(here, "include", "foo.toml") 300 301 # In the expected output, blue and yellow have the values from foo.toml 302 # (ocean, submarine) instead of the ones from include-example.toml 303 # (violets, daffodils), because the defaults in the included file take 304 # precedence over the values from the parent. 305 include_output = """[include/crash-handling] 306 foo = fleem 307 308 [fleem] 309 foo = bar 310 311 [include/flowers] 312 blue = ocean 313 foo = bar 314 red = roses 315 yellow = submarine 316 317 """ 318 included_output = """[include/flowers] 319 blue = ocean 320 yellow = submarine 321 322 """ 323 324 parser = ManifestParser( 325 manifests=(include_example, included_foo), rootdir=here, use_toml=True 326 ) 327 self.assertEqual( 328 parser.get("name"), ["crash-handling", "fleem", "flowers", "flowers"] 329 ) 330 self.assertEqual( 331 [ 332 (test["name"], os.path.basename(test["manifest"])) 333 for test in parser.tests 334 ], 335 [ 336 ("crash-handling", "bar.toml"), 337 ("fleem", "include-example.toml"), 338 ("flowers", "foo.toml"), 339 ("flowers", "foo.toml"), 340 ], 341 ) 342 self.check_included_repeat( 343 parser, 344 parser.tests[3], 345 parser.tests[2], 346 include_output + included_output, 347 True, 348 ) 349 350 # Same tests, but with the load order of the manifests swapped. 351 parser = ManifestParser( 352 manifests=(included_foo, include_example), rootdir=here, use_toml=True 353 ) 354 self.assertEqual( 355 parser.get("name"), ["flowers", "crash-handling", "fleem", "flowers"] 356 ) 357 self.assertEqual( 358 [ 359 (test["name"], os.path.basename(test["manifest"])) 360 for test in parser.tests 361 ], 362 [ 363 ("flowers", "foo.toml"), 364 ("crash-handling", "bar.toml"), 365 ("fleem", "include-example.toml"), 366 ("flowers", "foo.toml"), 367 ], 368 ) 369 self.check_included_repeat( 370 parser, 371 parser.tests[0], 372 parser.tests[3], 373 included_output + include_output, 374 True, 375 ) 376 377 def check_included_repeat( 378 self, parser, isolated_test, included_test, expected_output, use_toml=False 379 ): 380 if use_toml: 381 include_example_filename = "include-example.toml" 382 foo_filename = "foo.toml" 383 else: 384 include_example_filename = "include-example.toml" 385 foo_filename = "foo.toml" 386 include_example = os.path.join(here, include_example_filename) 387 included_foo = os.path.join(here, "include", foo_filename) 388 ancestor_ini = os.path.relpath(include_example, parser.rootdir) 389 manifest_default_key = (ancestor_ini, included_foo) 390 391 self.assertFalse("ancestor_manifest" in isolated_test) 392 self.assertEqual(included_test["ancestor_manifest"], include_example_filename) 393 394 self.assertTrue(include_example in parser.manifest_defaults) 395 self.assertTrue(included_foo in parser.manifest_defaults) 396 self.assertTrue(manifest_default_key in parser.manifest_defaults) 397 self.assertEqual( 398 parser.manifest_defaults[manifest_default_key], 399 { 400 "foo": "bar", 401 "here": os.path.join(here, "include"), 402 "red": "roses", 403 "blue": "ocean", 404 "yellow": "daffodils", 405 }, 406 ) 407 408 buffer = StringIO() 409 parser.write(fp=buffer) 410 self.assertEqual(buffer.getvalue(), expected_output) 411 412 def test_invalid_path_toml(self): 413 """ 414 Test invalid path should not throw when not strict (TOML) 415 """ 416 manifest = os.path.join(here, "include-invalid.toml") 417 ManifestParser(manifests=(manifest,), strict=False, use_toml=True) 418 419 def test_copy_toml(self): 420 """Test our ability to copy a set of manifests (TOML)""" 421 422 tempdir = tempfile.mkdtemp() 423 include_example = os.path.join(here, "include-example.toml") 424 manifest = ManifestParser(manifests=(include_example,), use_toml=True) 425 manifest.copy(tempdir) 426 self.assertEqual( 427 sorted(os.listdir(tempdir)), ["fleem", "include", "include-example.toml"] 428 ) 429 self.assertEqual( 430 sorted(os.listdir(os.path.join(tempdir, "include"))), 431 ["bar.toml", "crash-handling", "flowers", "foo.toml"], 432 ) 433 from_manifest = ManifestParser(manifests=(include_example,), use_toml=True) 434 to_manifest = os.path.join(tempdir, "include-example.toml") 435 to_manifest = ManifestParser(manifests=(to_manifest,), use_toml=True) 436 self.assertEqual(to_manifest.get("name"), from_manifest.get("name")) 437 shutil.rmtree(tempdir) 438 439 def test_path_override_toml(self): 440 """You can override the path in the section too. 441 This shows that you can use a relative path""" 442 path_example = os.path.join(here, "path-example.toml") 443 manifest = ManifestParser(manifests=(path_example,), use_toml=True) 444 self.assertEqual(manifest.tests[0]["path"], os.path.join(here, "fleem")) 445 446 def test_relative_path_toml(self): 447 """ 448 Relative test paths are correctly calculated. (TOML) 449 """ 450 relative_path = os.path.join(here, "relative-path.toml") 451 manifest = ManifestParser(manifests=(relative_path,), use_toml=True) 452 self.assertEqual( 453 manifest.tests[0]["path"], os.path.join(os.path.dirname(here), "fleem") 454 ) 455 self.assertEqual(manifest.tests[0]["relpath"], os.path.join("..", "fleem")) 456 self.assertEqual( 457 manifest.tests[1]["relpath"], os.path.join("..", "testsSIBLING", "example") 458 ) 459 460 def test_path_from_fd(self): 461 """ 462 Test paths are left untouched when manifest is a file-like object. 463 """ 464 fp = StringIO("[section]\npath=fleem") 465 manifest = ManifestParser(manifests=(fp,)) 466 self.assertEqual(manifest.tests[0]["path"], "fleem") 467 self.assertEqual(manifest.tests[0]["relpath"], "fleem") 468 self.assertEqual(manifest.tests[0]["manifest"], None) 469 470 def test_comments_toml(self): 471 """ 472 ensure comments work, see 473 https://bugzilla.mozilla.org/show_bug.cgi?id=813674 474 (TOML) 475 """ 476 comment_example = os.path.join(here, "comment-example.toml") 477 manifest = ManifestParser(manifests=(comment_example,), use_toml=True) 478 self.assertEqual(len(manifest.tests), 8) 479 names = [i["name"] for i in manifest.tests] 480 self.assertFalse("test_0202_app_launch_apply_update_dirlocked.js" in names) 481 482 def test_verifyDirectory_toml(self): 483 directory = os.path.join(here, "verifyDirectory") 484 485 # correct manifest 486 manifest_path = os.path.join(directory, "verifyDirectory.toml") 487 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True) 488 missing = manifest.verifyDirectory(directory, extensions=(".js",)) 489 self.assertEqual(missing, (set(), set())) 490 491 # manifest is missing test_1.js 492 test_1 = os.path.join(directory, "test_1.js") 493 manifest_path = os.path.join(directory, "verifyDirectory_incomplete.toml") 494 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True) 495 missing = manifest.verifyDirectory(directory, extensions=(".js",)) 496 self.assertEqual(missing, (set(), set([test_1]))) 497 498 # filesystem is missing test_notappearinginthisfilm.js 499 missing_test = os.path.join(directory, "test_notappearinginthisfilm.js") 500 manifest_path = os.path.join(directory, "verifyDirectory_toocomplete.toml") 501 manifest = ManifestParser(manifests=(manifest_path,), use_toml=True) 502 missing = manifest.verifyDirectory(directory, extensions=(".js",)) 503 self.assertEqual(missing, (set([missing_test]), set())) 504 505 def test_just_defaults_toml(self): 506 """Ensure a manifest with just a DEFAULT section exposes that data. (TOML)""" 507 508 parser = ManifestParser(use_toml=True) 509 manifest = os.path.join(here, "just-defaults.toml") 510 parser.read(manifest) 511 self.assertEqual(len(parser.tests), 0) 512 self.assertTrue(manifest in parser.manifest_defaults) 513 self.assertEqual(parser.manifest_defaults[manifest]["foo"], "bar") 514 515 def test_manifest_list_toml(self): 516 """ 517 Ensure a manifest with just a DEFAULT section still returns 518 itself from the manifests() method. (TOML) 519 """ 520 521 parser = ManifestParser(use_toml=True) 522 manifest = os.path.join(here, "no-tests.toml") 523 parser.read(manifest) 524 self.assertEqual(len(parser.tests), 0) 525 self.assertTrue(len(parser.manifests()) == 1) 526 527 def test_manifest_with_invalid_condition_toml(self): 528 """ 529 Ensure a skip-if or similar condition with an assignment in it 530 causes errors. (TOML) 531 """ 532 533 parser = ManifestParser(use_toml=True) 534 manifest = os.path.join(here, "broken-skip-if.toml") 535 with self.assertRaisesRegex( 536 Exception, "Should not assign in skip-if list condition for DEFAULT" 537 ): 538 parser.read(manifest) 539 540 def test_parse_error_toml(self): 541 """ 542 Verify handling of a mal-formed TOML file 543 """ 544 545 parser = ManifestParser(use_toml=True) 546 manifest = os.path.join(here, "parse-error.toml") 547 with self.assertRaisesRegex( 548 Exception, 549 r".*'str' object has no attribute 'keys'.*", 550 ): 551 parser.read(manifest) 552 553 def test_parse_error_tomlkit(self): 554 """ 555 Verify handling of a mal-formed TOML file 556 """ 557 558 parser = ManifestParser(use_toml=True, document=True) 559 manifest = os.path.join(here, "parse-error.toml") 560 with self.assertRaisesRegex( 561 Exception, 562 r".*'String' object has no attribute 'keys'.*", 563 ): 564 parser.read(manifest) 565 566 def test_edit_manifest(self): 567 """ 568 Verify reading and writing TOML manifest with tomlkit 569 """ 570 parser = ManifestParser(use_toml=True, document=True) 571 before = "edit-manifest-before.toml" 572 before_path = os.path.join(here, before) 573 parser.read(before_path) 574 assert before_path in parser.source_documents 575 manifest = parser.source_documents[before_path] 576 assert manifest is not None 577 assert isinstance(manifest, TOMLDocument) 578 579 filename = "bug_20.js" 580 assert filename in manifest 581 condition = "os == 'mac'" 582 bug = "Bug 20" 583 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 584 condition = "os == 'windows'" 585 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 586 587 filename = "test_foo.html" 588 assert filename in manifest 589 condition = "os == 'mac' && debug" 590 manifestparser.toml.add_skip_if(manifest, filename, condition) 591 592 filename = "test_bar.html" 593 assert filename in manifest 594 condition = "tsan" 595 bug = "Bug 444" 596 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 597 condition = "os == 'linux'" # pre-existing, should be ignored 598 bug = "Bug 555" 599 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 600 601 filename = "bug_100.js" 602 assert filename in manifest 603 condition = "apple_catalina" 604 bug = "Bug 200" 605 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 606 condition = "os == 'android' && os_version == '14' && ccov" 607 bug = "Bug 99999" 608 (additional_comment, carryover, bug_reference) = ( 609 manifestparser.toml.add_skip_if( 610 manifest, filename, condition, bug, None, True 611 ) 612 ) 613 assert not additional_comment 614 assert carryover 615 assert bug_reference == "Bug 100, will be carried over" 616 617 filename = "bug_3.js" 618 assert filename in manifest 619 condition = "verify" 620 bug = "Bug 33333" 621 manifestparser.toml.add_skip_if(manifest, filename, condition, bug) 622 623 # Should not extend exising conditions 624 filename = "test_extend_linux.js" 625 assert filename in manifest 626 condition = "os == 'linux' && version == '18.04'" 627 manifestparser.toml.add_skip_if(manifest, filename, condition) 628 629 # Should simplify exising conditions 630 filename = "test_simplify_linux.js" 631 assert filename in manifest 632 condition = "os == 'win'" 633 manifestparser.toml.add_skip_if(manifest, filename, condition) 634 635 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest) 636 after = "edit-manifest-after.toml" 637 after_path = os.path.join(here, after) 638 after_str = open(after_path, encoding="utf-8").read() 639 assert manifest_str == after_str 640 641 def test_remove_skipif(self): 642 """ 643 Verify removing skip-if conditions from TOML manifest 644 """ 645 parser = ManifestParser(use_toml=True, document=True) 646 before = "remove-manifest-before.toml" 647 before_path = os.path.join(here, before) 648 parser.read(before_path) 649 manifest = parser.source_documents[before_path] 650 651 manifestparser.toml.remove_skip_if(manifest, os_name="linux") 652 653 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest) 654 after = "remove-manifest-after1.toml" 655 after_path = os.path.join(here, after) 656 after_str = open(after_path, encoding="utf-8").read() 657 assert manifest_str == after_str 658 659 parser.read(before_path) 660 manifest = parser.source_documents[before_path] 661 662 manifestparser.toml.remove_skip_if( 663 manifest, os_name="linux", os_version="22.04" 664 ) 665 666 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest) 667 after = "remove-manifest-after2.toml" 668 after_path = os.path.join(here, after) 669 after_str = open(after_path, encoding="utf-8").read() 670 assert manifest_str == after_str 671 672 parser.read(before_path) 673 manifest = parser.source_documents[before_path] 674 675 manifestparser.toml.remove_skip_if( 676 manifest, os_name="linux", os_version="22.04", processor="x86" 677 ) 678 679 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest) 680 after = "remove-manifest-after3.toml" 681 after_path = os.path.join(here, after) 682 after_str = open(after_path, encoding="utf-8").read() 683 assert manifest_str == after_str 684 685 parser.read(before_path) 686 manifest = parser.source_documents[before_path] 687 688 manifestparser.toml.remove_skip_if( 689 manifest, os_name="unknown", os_version="22.04", processor="x86" 690 ) 691 692 manifest_str = manifestparser.toml.alphabetize_toml_str(manifest) 693 after = "remove-manifest-before.toml" 694 after_path = os.path.join(here, after) 695 after_str = open(after_path, encoding="utf-8").read() 696 assert manifest_str == after_str 697 698 parser.read(before_path) 699 manifest = parser.source_documents[before_path] 700 701 with pytest.raises(ValueError): 702 manifestparser.toml.remove_skip_if(manifest) 703 704 705 if __name__ == "__main__": 706 mozunit.main()