tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_python_manifest_parser.py (859B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 import mozunit
      6 import pytest
      7 
      8 
      9 @pytest.fixture
     10 def parse(normalize):
     11    reftest = pytest.importorskip("reftest")
     12 
     13    def inner(path):
     14        mp = reftest.ReftestManifest()
     15        mp.load(normalize(path))
     16        return mp
     17 
     18    return inner
     19 
     20 
     21 def test_parse_defaults(parse):
     22    mp = parse("defaults.list")
     23    assert len(mp.tests) == 4
     24 
     25    for test in mp.tests:
     26        if test["name"].startswith("foo"):
     27            assert test["pref"] == "foo.bar,true"
     28        else:
     29            assert "pref" not in test
     30 
     31    # invalid defaults
     32    with pytest.raises(ValueError):
     33        parse("invalid-defaults.list")
     34 
     35 
     36 if __name__ == "__main__":
     37    mozunit.main()