def test_execute_interrupted(make_one, tmpdir): session = make_one('test', 'sig', mock.Mock(), MockConfig()) def mock_run_commands(): raise KeyboardInterrupt() session.config = MockConfig(_dir='.') session._create_config = mock.Mock() session._create_venv = mock.Mock() session._run_commands = mock_run_commands with pytest.raises(KeyboardInterrupt): session.execute()
def test_execute_interrupted(make_one, tmpdir): session = make_one('test', 'sig', mock.Mock(), MockConfig()) def mock_run_commands(): raise KeyboardInterrupt() session.config = MockConfig(_dir='.') session._create_config = mock.Mock() session._create_venv = mock.Mock() session._install_dependencies = mock.Mock() session._run_commands = mock_run_commands with pytest.raises(KeyboardInterrupt): session.execute()
def test_execute_session_quit(make_one): def bad_config(session): session.error('meep') session = make_one('test', 'sig', bad_config, MockConfig(posargs=[])) assert not session.execute()
def test_execute_chdir(make_one, tmpdir): tmpdir.join('dir2').ensure(dir=True) session = make_one('test', 'sig', mock.Mock(), MockConfig()) session.venv = mock.Mock() session.venv.env = {} current_cwd = os.getcwd() observed_cwds = [] def observe_cwd(): observed_cwds.append(os.getcwd()) commands = [ nox.command.FunctionCommand(os.chdir, [tmpdir.strpath]), nox.command.FunctionCommand(observe_cwd), nox.command.FunctionCommand(os.chdir, [tmpdir.join('dir2').strpath]), nox.command.FunctionCommand(observe_cwd), ] session.config = MockConfig(_commands=commands, env={}) session._create_config = mock.Mock() session._create_venv = mock.Mock() assert session.execute() assert observed_cwds == [tmpdir.strpath, tmpdir.join('dir2').strpath] assert os.getcwd() == current_cwd
def test_execute_error(make_one, tmpdir): session = make_one('test', 'sig', mock.Mock(), MockConfig()) def mock_run_commands(): raise nox.command.CommandFailed('test') session.config = MockConfig(_dir='.') session._create_config = mock.Mock() session._create_venv = mock.Mock() session._run_commands = mock_run_commands assert not session.execute()
def test_execute_chdir(make_one, tmpdir): session = make_one('test', 'sig', mock.Mock(), MockConfig()) def mock_run_commands(): assert os.getcwd() == tmpdir.strpath session.config = MockConfig(_dir=tmpdir.strpath) session._create_config = mock.Mock() session._create_venv = mock.Mock() session._install_dependencies = mock.Mock() session._run_commands = mock_run_commands assert session.execute()
def test_execute(make_one): session = make_one('test', 'sig', mock.Mock(), MockConfig()) session.config = MockConfig() session._create_config = mock.Mock() session._create_venv = mock.Mock() session._run_commands = mock.Mock() assert session.execute() assert session._create_config.called assert session._create_venv.called assert session._run_commands.called
def test_execute_error(make_one, tmpdir): session = make_one('test', 'sig', mock.Mock(), MockConfig()) def mock_run_commands(): raise nox.command.CommandFailed('test') session.config = MockConfig(_dir='.') session._create_config = mock.Mock() session._create_venv = mock.Mock() session._install_dependencies = mock.Mock() session._run_commands = mock_run_commands assert not session.execute()
def test_execute(make_one): session = make_one('test', 'sig', mock.Mock(), MockConfig()) session.config = MockConfig(_dir='.') session._create_config = mock.Mock() session._create_venv = mock.Mock() session._install_dependencies = mock.Mock() session._run_commands = mock.Mock() assert session.execute() assert session._create_config.called assert session._create_venv.called assert session._install_dependencies.called assert session._run_commands.called