diff --git a/cirq-google/cirq_google/engine/engine_processor_test.py b/cirq-google/cirq_google/engine/engine_processor_test.py index 5847ffa0647..1e4c74d4886 100644 --- a/cirq-google/cirq_google/engine/engine_processor_test.py +++ b/cirq-google/cirq_google/engine/engine_processor_test.py @@ -808,7 +808,7 @@ def test_get_schedule_time_filter_behavior(list_time_slots): processor.get_schedule(from_time=datetime.timedelta(seconds=200), to_time=None) list_time_slots.assert_called_with('proj', 'p0', f'end_time > {now + 200}') - test_timestamp = datetime.datetime.utcfromtimestamp(52) + test_timestamp = datetime.datetime.fromtimestamp(52, datetime.UTC) utc_ts = int(test_timestamp.timestamp()) processor.get_schedule(from_time=test_timestamp, to_time=None) list_time_slots.assert_called_with('proj', 'p0', f'end_time > {utc_ts}') @@ -852,7 +852,7 @@ def test_list_reservations_time_filter_behavior(list_reservations): processor.list_reservations(from_time=datetime.timedelta(seconds=200), to_time=None) list_reservations.assert_called_with('proj', 'p0', f'end_time > {now + 200}') - test_timestamp = datetime.datetime.utcfromtimestamp(52) + test_timestamp = datetime.datetime.fromtimestamp(52, datetime.UTC) utc_ts = int(test_timestamp.timestamp()) processor.list_reservations(from_time=test_timestamp, to_time=None) list_reservations.assert_called_with('proj', 'p0', f'end_time > {utc_ts}') diff --git a/cirq-ionq/cirq_ionq/ionq_client.py b/cirq-ionq/cirq_ionq/ionq_client.py index 5e7d9e4fce4..ccfa6f0db7d 100644 --- a/cirq-ionq/cirq_ionq/ionq_client.py +++ b/cirq-ionq/cirq_ionq/ionq_client.py @@ -338,7 +338,7 @@ def list_calibrations( """ params = {} - epoch = datetime.datetime.utcfromtimestamp(0) + epoch = datetime.datetime.fromtimestamp(0, datetime.UTC) if start: params['start'] = int((start - epoch).total_seconds() * 1000) if end: diff --git a/cirq-ionq/cirq_ionq/ionq_client_test.py b/cirq-ionq/cirq_ionq/ionq_client_test.py index 50798ea037b..dad5b425e86 100644 --- a/cirq-ionq/cirq_ionq/ionq_client_test.py +++ b/cirq-ionq/cirq_ionq/ionq_client_test.py @@ -40,7 +40,7 @@ def test_ionq_client_invalid_remote_host(): for invalid_url in ('', 'url', 'http://', 'ftp://', 'http://'): with pytest.raises(AssertionError, match='not a valid url'): _ = ionq.ionq_client._IonQClient(remote_host=invalid_url, api_key='a') - with pytest.raises(AssertionError, match=invalid_url): + with pytest.raises(AssertionError, match=invalid_url or None): _ = ionq.ionq_client._IonQClient(remote_host=invalid_url, api_key='a') @@ -1050,8 +1050,8 @@ def test_ionq_client_list_calibrations_dates(mock_get): mock_get.return_value.json.return_value = {'calibrations': [{'id': '1'}, {'id': '2'}]} client = ionq.ionq_client._IonQClient(remote_host='http://example.com', api_key='to_my_heart') response = client.list_calibrations( - start=datetime.datetime.utcfromtimestamp(1284286794), - end=datetime.datetime.utcfromtimestamp(1284286795), + start=datetime.datetime.fromtimestamp(1284286794, datetime.UTC), + end=datetime.datetime.fromtimestamp(1284286795, datetime.UTC), ) assert response == [{'id': '1'}, {'id': '2'}] diff --git a/cirq-ionq/cirq_ionq/service_test.py b/cirq-ionq/cirq_ionq/service_test.py index 88cc39817af..ce2957c1801 100644 --- a/cirq-ionq/cirq_ionq/service_test.py +++ b/cirq-ionq/cirq_ionq/service_test.py @@ -209,8 +209,8 @@ def test_service_list_calibrations(): calibrations = [{'id': '1', 'qubits': '1'}, {'id': '2', 'qubits': 2}] mock_client.list_calibrations.return_value = calibrations service._client = mock_client - start = datetime.datetime.utcfromtimestamp(1284286794) - end = datetime.datetime.utcfromtimestamp(1284286795) + start = datetime.datetime.fromtimestamp(1284286794, datetime.UTC) + end = datetime.datetime.fromtimestamp(1284286795, datetime.UTC) listed_calibrations = service.list_calibrations(start=start, end=end, limit=10, batch_size=2) assert listed_calibrations[0].num_qubits() == 1