test_print_tests.py (1173B)
1 import os 2 3 import mozunit 4 import pytest 5 6 # need this so raptor imports work both from /raptor and via mach 7 here = os.path.abspath(os.path.dirname(__file__)) 8 from raptor import cmdline 9 10 11 def test_pageload_subtests(capsys, monkeypatch, tmpdir): 12 # cmdline.py is hard-coded to use raptor.toml from the same directory so we need 13 # to monkey patch os.dirname, which is not ideal. If we could make --print-tests 14 # respect the --test path that would be much better. 15 def mock(path): 16 return str(tmpdir) 17 18 monkeypatch.setattr(os.path, "dirname", mock) 19 manifest = tmpdir.join("raptor.toml") 20 manifest.write( 21 """ 22 [DEFAULT] 23 type = "pageload" 24 apps = "firefox" 25 26 ["raptor-subtest-1"] 27 measure = ["foo", "bar"] 28 29 ["raptor-subtest-2"] 30 """ 31 ) 32 with pytest.raises(SystemExit): 33 cmdline.parse_args(["--print-tests"]) 34 captured = capsys.readouterr() 35 assert ( 36 captured.out 37 == """ 38 Raptor Tests Available for Firefox Desktop 39 ========================================== 40 41 raptor 42 type: pageload 43 subtests: 44 raptor-subtest-1 (foo, bar) 45 raptor-subtest-2 46 47 Done. 48 """ 49 ) 50 51 52 if __name__ == "__main__": 53 mozunit.main()