def test_snippets_errors(actions, snippets): _actions = [] @actions.add(name='my_test', alias='t') def test(arg): # Enforce single-character argument. assert len(str(arg)) == 1 _actions.append(arg) with captured_logging() as buf: snippets.run(':t1') assert 'couldn\'t' in buf.getvalue().lower() with captured_logging() as buf: snippets.run(':t') assert 'error' in buf.getvalue().lower() with captured_logging() as buf: snippets.run(':t 1 2') assert 'error' in buf.getvalue().lower() with captured_logging() as buf: snippets.run(':t aa') assert 'assert 2 == 1' in buf.getvalue() snippets.run(':t a') assert _actions == ['a']
def test_download_already_exists_invalid(tempdir, mock_url): with captured_logging() as buf: path = op.join(tempdir, 'test') # Create empty file. open(path, 'a').close() _check(_dl(path)) assert 'redownload' in buf.getvalue()
def test_download_already_exists_valid(tempdir, mock_url): with captured_logging() as buf: path = op.join(tempdir, 'test') # Create valid file. with open(path, 'ab') as f: f.write(_DATA.tostring()) _check(_dl(path)) assert 'skip' in buf.getvalue()