code: def test_nested_credentials(monkeypatch):
      """Check that rasterio.open() doesn't wipe out surrounding credentials"""
  
      @ensure_env_with_credentials
      def fake_opener(path):
          return fiona.env.getenv()
  
      with fiona.env.Env(
          session=AWSSession(
              aws_access_key_id="foo", aws_secret_access_key="bar"
          )
      ):
          assert fiona.env.getenv()["AWS_ACCESS_KEY_ID"] == "foo"
          assert fiona.env.getenv()["AWS_SECRET_ACCESS_KEY"] == "bar"
  
          monkeypatch.setenv("AWS_ACCESS_KEY_ID", "lol")
          monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "wut")
          gdalenv = fake_opener("s3://foo/bar")
          assert gdalenv["AWS_ACCESS_KEY_ID"] == "foo"
          assert gdalenv["AWS_SECRET_ACCESS_KEY"] == "bar"
  
file_path: Fiona/tests/test_env.py
imports: import os
  import sys
  from unittest import mock
  import boto3
  import pytest
  import fiona
  from fiona import _env
  from fiona.env import getenv, hasenv, ensure_env, ensure_env_with_credentials
  from fiona.errors import FionaDeprecationWarning
  from fiona.session import AWSSession, GSSession
label_desc: Use image node_id 1 for calling a global function with example usage: test_nested_credentials(monkeypatch) and returns: fiona