def test_undecorated_function_w_param(monkeypatch, tmp_sample_dir): monkeypatch.setattr(sys, 'argv', [ 'python', '--entry-point', 'test_pkg.entry.plain_function_w_param', 'some_value_for_param' ]) build.main(catch_exception=False)
def test_invalid_spec_entry_point(args, monkeypatch_session): monkeypatch_session.setattr(sys, 'argv', ['python'] + args) with pytest.raises(ValueError) as excinfo: build.main(catch_exception=False) assert 'Could not determine the entry point type' in str(excinfo.value)
def test_invalid_function(monkeypatch): monkeypatch.setattr( sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.invalid_function']) with pytest.raises(AttributeError): build.main(catch_exception=False)
def test_invalid_spec_entry_point(args, monkeypatch): monkeypatch.setattr(sys, 'argv', ['python'] + args) with pytest.raises(ValueError) as excinfo: build.main(catch_exception=False) assert 'YAML file is expected' in str(excinfo.value)
def test_invalid_entry_point_value(monkeypatch): monkeypatch.setattr(sys, 'argv', ['python', '--entry-point', 'invalid_entry_point']) with pytest.raises(ValueError) as excinfo: build.main(catch_exception=False) assert 'Could not determine the entry point type' in str(excinfo.value)
def test_build_uses_telemetry(monkeypatch, tmp_directory): _write_sample_conda_env() Path('setup.py').write_text(setup_py) mock = Mock() monkeypatch.setattr(sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.with_doc']) monkeypatch.setattr(build.telemetry, "log_api", mock) build.main(catch_exception=False) assert mock.call_count == 1
def test_build_help_shows_docstring(capsys, monkeypatch): monkeypatch.setattr( sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.with_doc', '--help']) with pytest.raises(SystemExit) as excinfo: build.main(catch_exception=False) out, _ = capsys.readouterr() assert not excinfo.value.code assert 'This is some description' in out
def test_build(monkeypatch, tmp_sample_dir): monkeypatch.setattr(sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.with_doc']) build.main(catch_exception=False)
def test_build_with_replaced_env_value(tmp_nbs, monkeypatch): monkeypatch.setattr( sys, 'argv', ['python', '--entry-point', 'pipeline.yaml', '--env--sample', 'True']) build.main(catch_exception=False)
def test_build_command(args, tmp_nbs, monkeypatch): args = ['python', '--entry-point', 'pipeline.yaml'] + args monkeypatch.setattr(sys, 'argv', args) build.main(catch_exception=False)
def test_nonexisting_module(monkeypatch): monkeypatch.setattr( sys, 'argv', ['python', '--entry-point', 'some_module.some_function']) with pytest.raises(ImportError): build.main(catch_exception=False)
def test_w_param(monkeypatch_session, tmp_sample_dir): monkeypatch_session.setattr(sys, 'argv', [ 'python', '--entry-point', 'test_pkg.entry.with_param', 'some_value_for_param' ]) build.main(catch_exception=False)
def test_replace_env_value(monkeypatch, tmp_sample_dir): monkeypatch.setattr(sys, 'argv', [ 'python', '--entry-point', 'test_pkg.entry.with_doc', '--env--path--data', '/another/path' ]) build.main(catch_exception=False)
def test_undecorated_function(monkeypatch_session, tmp_sample_dir): monkeypatch_session.setattr( sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.plain_function']) build.main(catch_exception=False)
def test_invalid_doc(monkeypatch_session, tmp_sample_dir): monkeypatch_session.setattr( sys, 'argv', ['python', '--entry-point', 'test_pkg.entry.invalid_doc']) build.main(catch_exception=False)
def test_build_from_directory(arg, monkeypatch, tmp_nbs_no_yaml): Path('output').mkdir() monkeypatch.setattr(sys, 'argv', ['python', '--entry-point', arg]) build.main(catch_exception=False)
def test_log_enabled(monkeypatch_session, tmp_sample_dir): monkeypatch_session.setattr(sys, 'argv', [ 'python', '--entry-point', 'test_pkg.entry.with_doc', '--log', 'INFO' ]) build.main(catch_exception=False)