prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  AttributeError in `resource_name_to_date()` samples fixture
  See this samples [test run](https://source.cloud.google.com/results/invocations/e5c424d5-84a6-4505-ae44-3bc70fa94e44/targets/cloud-devrel%2Fclient-libraries%2Fpython%2Fgoogleapis%2Fpython-bigquery%2Fsamples%2Fpython3.6%2Fpresubmit/log). A bug in [this fixture](https://github.com/googleapis/python-bigquery/blob/bd7dbdae5c972b16bafc53c67911eeaa3255a880/samples/snippets/conftest.py#L33-L36) made all of them fail.
  
  > AttributeError: module 'datetime' has no attribute 'strptime'
  
  I wonder how this got in in the first place?
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `samples/snippets/conftest.py`
  Content:
  ```
  1 # Copyright 2020 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 import datetime
  16 import random
  17 
  18 from google.cloud import bigquery
  19 import pytest
  20 
  21 
  22 RESOURCE_PREFIX = "python_bigquery_samples_snippets"
  23 RESOURCE_DATE_FORMAT = "%Y%m%d_%H%M%S"
  24 RESOURCE_DATE_LENGTH = 4 + 2 + 2 + 1 + 2 + 2 + 2
  25 
  26 
  27 def resource_prefix() -> str:
  28     timestamp = datetime.datetime.utcnow().strftime(RESOURCE_DATE_FORMAT)
  29     random_string = hex(random.randrange(1000000))[2:]
  30     return f"{RESOURCE_PREFIX}_{timestamp}_{random_string}"
  31 
  32 
  33 def resource_name_to_date(resource_name: str):
  34     start_date = len(RESOURCE_PREFIX) + 1
  35     date_string = resource_name[start_date : start_date + RESOURCE_DATE_LENGTH]
  36     return datetime.strptime(date_string, RESOURCE_DATE_FORMAT)
  37 
  38 
  39 @pytest.fixture(scope="session", autouse=True)
  40 def cleanup_datasets(bigquery_client: bigquery.Client):
  41     yesterday = datetime.datetime.utcnow() - datetime.timedelta(days=1)
  42     for dataset in bigquery_client.list_datasets():
  43         if (
  44             dataset.dataset_id.startswith(RESOURCE_PREFIX)
  45             and resource_name_to_date(dataset.dataset_id) < yesterday
  46         ):
  47             bigquery_client.delete_dataset(
  48                 dataset, delete_contents=True, not_found_ok=True
  49             )
  50 
  51 
  52 @pytest.fixture(scope="session")
  53 def bigquery_client():
  54     bigquery_client = bigquery.Client()
  55     return bigquery_client
  56 
  57 
  58 @pytest.fixture(scope="session")
  59 def project_id(bigquery_client):
  60     return bigquery_client.project
  61 
  62 
  63 @pytest.fixture(scope="session")
  64 def dataset_id(bigquery_client: bigquery.Client, project_id: str):
  65     dataset_id = resource_prefix()
  66     full_dataset_id = f"{project_id}.{dataset_id}"
  67     dataset = bigquery.Dataset(full_dataset_id)
  68     bigquery_client.create_dataset(dataset)
  69     yield dataset_id
  70     bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True)
  71 
  72 
  73 @pytest.fixture
  74 def bigquery_client_patch(monkeypatch, bigquery_client):
  75     monkeypatch.setattr(bigquery, "Client", lambda: bigquery_client)
  76
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/samples/snippets/conftest.py b/samples/snippets/conftest.py
  --- a/samples/snippets/conftest.py
  +++ b/samples/snippets/conftest.py
  @@ -33,7 +33,7 @@
   def resource_name_to_date(resource_name: str):
       start_date = len(RESOURCE_PREFIX) + 1
       date_string = resource_name[start_date : start_date + RESOURCE_DATE_LENGTH]
  -    return datetime.strptime(date_string, RESOURCE_DATE_FORMAT)
  +    return datetime.datetime.strptime(date_string, RESOURCE_DATE_FORMAT)
   
   
   @pytest.fixture(scope="session", autouse=True)
  
verification_info: {"golden_diff": "diff --git a/samples/snippets/conftest.py b/samples/snippets/conftest.py\n--- a/samples/snippets/conftest.py\n+++ b/samples/snippets/conftest.py\n@@ -33,7 +33,7 @@\n def resource_name_to_date(resource_name: str):\n     start_date = len(RESOURCE_PREFIX) + 1\n     date_string = resource_name[start_date : start_date + RESOURCE_DATE_LENGTH]\n-    return datetime.strptime(date_string, RESOURCE_DATE_FORMAT)\n+    return datetime.datetime.strptime(date_string, RESOURCE_DATE_FORMAT)\n \n \n @pytest.fixture(scope=\"session\", autouse=True)\n", "issue": "AttributeError in `resource_name_to_date()` samples fixture\nSee this samples [test run](https://source.cloud.google.com/results/invocations/e5c424d5-84a6-4505-ae44-3bc70fa94e44/targets/cloud-devrel%2Fclient-libraries%2Fpython%2Fgoogleapis%2Fpython-bigquery%2Fsamples%2Fpython3.6%2Fpresubmit/log). A bug in [this fixture](https://github.com/googleapis/python-bigquery/blob/bd7dbdae5c972b16bafc53c67911eeaa3255a880/samples/snippets/conftest.py#L33-L36) made all of them fail.\r\n\r\n> AttributeError: module 'datetime' has no attribute 'strptime'\r\n\r\nI wonder how this got in in the first place?\r\n\n", "before_files": [{"content": "# Copyright 2020 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport datetime\nimport random\n\nfrom google.cloud import bigquery\nimport pytest\n\n\nRESOURCE_PREFIX = \"python_bigquery_samples_snippets\"\nRESOURCE_DATE_FORMAT = \"%Y%m%d_%H%M%S\"\nRESOURCE_DATE_LENGTH = 4 + 2 + 2 + 1 + 2 + 2 + 2\n\n\ndef resource_prefix() -> str:\n    timestamp = datetime.datetime.utcnow().strftime(RESOURCE_DATE_FORMAT)\n    random_string = hex(random.randrange(1000000))[2:]\n    return f\"{RESOURCE_PREFIX}_{timestamp}_{random_string}\"\n\n\ndef resource_name_to_date(resource_name: str):\n    start_date = len(RESOURCE_PREFIX) + 1\n    date_string = resource_name[start_date : start_date + RESOURCE_DATE_LENGTH]\n    return datetime.strptime(date_string, RESOURCE_DATE_FORMAT)\n\n\n@pytest.fixture(scope=\"session\", autouse=True)\ndef cleanup_datasets(bigquery_client: bigquery.Client):\n    yesterday = datetime.datetime.utcnow() - datetime.timedelta(days=1)\n    for dataset in bigquery_client.list_datasets():\n        if (\n            dataset.dataset_id.startswith(RESOURCE_PREFIX)\n            and resource_name_to_date(dataset.dataset_id) < yesterday\n        ):\n            bigquery_client.delete_dataset(\n                dataset, delete_contents=True, not_found_ok=True\n            )\n\n\n@pytest.fixture(scope=\"session\")\ndef bigquery_client():\n    bigquery_client = bigquery.Client()\n    return bigquery_client\n\n\n@pytest.fixture(scope=\"session\")\ndef project_id(bigquery_client):\n    return bigquery_client.project\n\n\n@pytest.fixture(scope=\"session\")\ndef dataset_id(bigquery_client: bigquery.Client, project_id: str):\n    dataset_id = resource_prefix()\n    full_dataset_id = f\"{project_id}.{dataset_id}\"\n    dataset = bigquery.Dataset(full_dataset_id)\n    bigquery_client.create_dataset(dataset)\n    yield dataset_id\n    bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True)\n\n\n@pytest.fixture\ndef bigquery_client_patch(monkeypatch, bigquery_client):\n    monkeypatch.setattr(bigquery, \"Client\", lambda: bigquery_client)\n", "path": "samples/snippets/conftest.py"}], "after_files": [{"content": "# Copyright 2020 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport datetime\nimport random\n\nfrom google.cloud import bigquery\nimport pytest\n\n\nRESOURCE_PREFIX = \"python_bigquery_samples_snippets\"\nRESOURCE_DATE_FORMAT = \"%Y%m%d_%H%M%S\"\nRESOURCE_DATE_LENGTH = 4 + 2 + 2 + 1 + 2 + 2 + 2\n\n\ndef resource_prefix() -> str:\n    timestamp = datetime.datetime.utcnow().strftime(RESOURCE_DATE_FORMAT)\n    random_string = hex(random.randrange(1000000))[2:]\n    return f\"{RESOURCE_PREFIX}_{timestamp}_{random_string}\"\n\n\ndef resource_name_to_date(resource_name: str):\n    start_date = len(RESOURCE_PREFIX) + 1\n    date_string = resource_name[start_date : start_date + RESOURCE_DATE_LENGTH]\n    return datetime.datetime.strptime(date_string, RESOURCE_DATE_FORMAT)\n\n\n@pytest.fixture(scope=\"session\", autouse=True)\ndef cleanup_datasets(bigquery_client: bigquery.Client):\n    yesterday = datetime.datetime.utcnow() - datetime.timedelta(days=1)\n    for dataset in bigquery_client.list_datasets():\n        if (\n            dataset.dataset_id.startswith(RESOURCE_PREFIX)\n            and resource_name_to_date(dataset.dataset_id) < yesterday\n        ):\n            bigquery_client.delete_dataset(\n                dataset, delete_contents=True, not_found_ok=True\n            )\n\n\n@pytest.fixture(scope=\"session\")\ndef bigquery_client():\n    bigquery_client = bigquery.Client()\n    return bigquery_client\n\n\n@pytest.fixture(scope=\"session\")\ndef project_id(bigquery_client):\n    return bigquery_client.project\n\n\n@pytest.fixture(scope=\"session\")\ndef dataset_id(bigquery_client: bigquery.Client, project_id: str):\n    dataset_id = resource_prefix()\n    full_dataset_id = f\"{project_id}.{dataset_id}\"\n    dataset = bigquery.Dataset(full_dataset_id)\n    bigquery_client.create_dataset(dataset)\n    yield dataset_id\n    bigquery_client.delete_dataset(dataset, delete_contents=True, not_found_ok=True)\n\n\n@pytest.fixture\ndef bigquery_client_patch(monkeypatch, bigquery_client):\n    monkeypatch.setattr(bigquery, \"Client\", lambda: bigquery_client)\n", "path": "samples/snippets/conftest.py"}]}