class_docstr: os.environ keys and values should be native strings, otherwise it will cause problems with other modules (notably
  subprocess). On Python 2 os.environ accepts anything without complaining, while Python 3 does the right thing
  and raises an error.
class_docstr_tok: ["os.environ","keys","and","values","should","be","native","strings",",","otherwise","it","will","cause","problems","with","other","modules","(","notably","subprocess",")",".","On","Python","2","os.environ","accepts","anything","without","complaining",",","while","Python","3","does","the","right","thing","and","raises","an","error","."]
code: def test_setenv_non_str_warning(
      self, monkeypatch: MonkeyPatch
  ) -> None:
      value = 2
      msg = (
          "Value of environment variable PYTEST_INTERNAL_MY_VAR type should be str, "
          "but got 2 (type: int); converted to str implicitly"
      )
      with pytest.warns(pytest.PytestWarning, match=re.escape(msg)):
          monkeypatch.setenv(str(self.VAR_NAME), value)
  
imports: import os
  import re
  import sys
  import textwrap
  from pathlib import Path
  from typing import Dict
  from typing import Generator
  from typing import Type
  import pytest
  from _pytest.monkeypatch import MonkeyPatch
  from _pytest.pytester import Pytester
label_desc: Use image node_id 1 for calling the TestEnvironWarnings obj's underlying member method code with example usage: obj.test_setenv_non_str_warning(monkeypatch) without return types