def test_calc_cutoff(capsys): partial_capture_fn = os.path.join(helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) mod.main('prog --coverage 14 1 {}'.format(partial_capture_fn).split()) out, err = capsys.readouterr() assert out == '2' assert not err
def test_calc_cutoff_err(): partial_capture_fn = os.path.join(helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) with pytest.raises(Exception) as excinfo: mod.main('prog --coverage 23 1 {}'.format(partial_capture_fn).split()) assert expected_err in str(excinfo.value)
def test_calc_cutoff_err(): partial_capture_fn = os.path.join( helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) with pytest.raises(Exception) as excinfo: mod.main('prog --coverage 23 1 {}'.format(partial_capture_fn).split()) assert expected_err in str(excinfo.value)
def test_calc_cutoff(capsys): partial_capture_fn = os.path.join( helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) mod.main('prog --coverage 14 1 {}'.format(partial_capture_fn).split()) out, err = capsys.readouterr() assert out == '2' assert not err
def test_calc_cutoff_errfile(monkeypatch, tmpdir): fn = str(tmpdir.mkdir('tmp').join('errfile')) monkeypatch.setenv('PBFALCON_ERRFILE', fn) partial_capture_fn = os.path.join(helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) with pytest.raises(Exception) as excinfo: mod.main('prog --coverage 23 1 {}'.format(partial_capture_fn).split()) assert expected_err in str(excinfo.value) assert expected_err in open(fn).read()
def test_calc_cutoff_errfile(monkeypatch, tmpdir): fn = str(tmpdir.mkdir('tmp').join('errfile')) monkeypatch.setenv('PBFALCON_ERRFILE', fn) partial_capture_fn = os.path.join( helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) with pytest.raises(Exception) as excinfo: mod.main('prog --coverage 23 1 {}'.format(partial_capture_fn).split()) assert expected_err in str(excinfo.value) assert expected_err in open(fn).read()
def test_calc_cutoff_errfile(monkeypatch, tmpdir): fn = str(tmpdir.mkdir('tmp').join('errfile')) monkeypatch.setenv('PBFALCON_ERRFILE', fn) partial_capture_fn = os.path.join(helpers.get_test_data_dir(), 'calc_cutoff/partial_capture.txt') assert os.path.exists(partial_capture_fn) with pytest.raises(Exception) as excinfo: mod.main('prog --coverage 23 1 {}'.format(partial_capture_fn).split()) #assert expected_err0 in str(excinfo.value) assert expected_err1 in str(excinfo.value) with open(fn) as sin: errfile_content = sin.read() assert expected_err0 in errfile_content assert expected_err1 in errfile_content # Also check new 'alarms.json' encoded0 = json.dumps(expected_err0)[ 1:-1] # actually just escapes the newlines encoded1 = json.dumps(expected_err1)[1:-1] with open('alarms.json') as sin: alarm_content = sin.read() assert encoded0 in alarm_content assert encoded1 in alarm_content
def test_help(): try: mod.main(['prog', '--help']) except SystemExit: pass