Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't try to use token if it is falsy #234

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@

### Bug fixes

* Do not try to connect with an IBMQX token if it is falsy.
[(#234)](https://github.com/PennyLaneAI/pennylane-qiskit/pull/234)

### Contributors

This release contains contributions from (in alphabetical order):

Matthew Silverman

---
# Release 0.27.0

Expand Down
2 changes: 1 addition & 1 deletion pennylane_qiskit/ibmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def connect(kwargs):
url = kwargs.get("ibmqx_url", None) or os.getenv("IBMQX_URL")

# TODO: remove "no cover" when #173 is resolved
if token is not None: # pragma: no cover
if token: # pragma: no cover
# token was provided by the user, so attempt to enable an
# IBM Q account manually
def login():
Expand Down
7 changes: 7 additions & 0 deletions tests/test_ibmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def test_load_kwargs_takes_precedence(token, monkeypatch):
assert dev.provider.credentials.is_ibmq()


def test_load_env_empty_string_has_short_error(monkeypatch):
"""Test that the empty string is treated as a missing token."""
monkeypatch.setenv("IBMQX_TOKEN", "")
with pytest.raises(IBMQAccountError, match="No active IBM Q account"):
IBMQDevice(wires=1)


def test_account_already_loaded(token):
"""Test loading an IBMQ device using
an already loaded account"""
Expand Down