code: def test_credentials_from_env():
      keyring = Keyring()
      cred = AWS_S3("test-s3", keyring=keyring)
      assert_false(cred.is_known)
      assert_equal(cred.get("key_id"), None)
      assert_equal(cred.get("secret_id"), None)
  
      def _check1():
          assert_equal(cred.get("key_id"), "1")
          assert_false(cred.is_known)
  
      def _check2():
          assert_equal(cred.get("key_id"), "1")
          assert_equal(cred.get("secret_id"), "2")
          assert_true(cred.is_known)
  
      # this is the old way, should still work
      with patch.dict("os.environ", {"DATALAD_test_s3_key_id": "1"}):
          _check1()
          with patch.dict(
              "os.environ", {"DATALAD_test_s3_secret_id": "2"}
          ):
              _check2()
          assert_false(cred.is_known)  # no memory of the past
  
      # here is the new way
      import datalad
  
      try:
          with patch.dict(
              "os.environ", {"DATALAD_CREDENTIAL_test__s3_key__id": "1"}
          ):
              datalad.cfg.reload()
              _check1()
              with patch.dict(
                  "os.environ",
                  {"DATALAD_CREDENTIAL_test__s3_secret__id": "2"},
              ):
                  datalad.cfg.reload()
                  _check2()
              datalad.cfg.reload()
              assert_false(cred.is_known)  # no memory of the past
      finally:
          datalad.cfg.reload()
  
file_path: datalad/datalad/downloaders/tests/test_credentials.py
imports: from unittest.mock import patch
  from datalad import cfg
  from datalad.api import Dataset
  from datalad.support.external_versions import external_versions
  from datalad.support.keyring_ import Keyring, MemoryKeyring
  from datalad.tests.utils_pytest import SkipTest, assert_equal, assert_false, assert_in, assert_raises, assert_true, ok_file_has_content, skip_if, with_tempfile, with_testsui
  from ..credentials import AWS_S3, CompositeCredential, GitCredential, UserPassword
label_desc: Use image node_id 6 for calling a global function with example usage: test_credentials_from_env() without return types