class_docstr: Check functionality and edge cases of `report_results` helper interface.
class_docstr_tok: ["Check","functionality","and","edge","cases","of","`","report_results","`","helper","interface","."]
docstr: Check that a file with correct data will be written to an existing
  file in a legit path.
docstr_tok: ["Check","that","a","file","with","correct","data","will","be","written","to","an","existing","file","in","a","legit","path","."]
code: def test_with_correct_env(self, monkeypatch, capsys, tmpdir, data):
      """Check that a file with correct data will be written to an existing
      file in a legit path.
      """
      path = str(tmpdir.join("naedw.txt"))
      with open(path, mode="w"):
          pass
      monkeypatch.setenv("ORION_RESULTS_PATH", path)
      reloaded_client = reload(cli)
  
      assert reloaded_client.IS_ORION_ON is True
      assert reloaded_client.RESULTS_FILENAME == path
      assert reloaded_client._HAS_REPORTED_RESULTS is False
  
      reloaded_client.report_results(data)
      out, err = capsys.readouterr()
      assert reloaded_client._HAS_REPORTED_RESULTS is True
      assert out == ""
      assert err == ""
  
      with open(path) as results_file:
          res = json.load(results_file)
      assert res == data
  
imports: import copy
  import json
  from importlib import reload
  import pytest
  import orion.client
  import orion.client.cli
  import orion.core
  from orion.algo.random import Random
  from orion.client import get_experiment
  from orion.client.experiment import ExperimentClient
  from orion.core.io.database.ephemeraldb import EphemeralDB
  from orion.core.io.database.pickleddb import PickledDB
  from orion.core.utils.exceptions import BranchingEvent, NoConfigurationError, RaceCondition, UnsupportedOperation
  from orion.storage.base import setup_storage
  from orion.storage.legacy import Legacy
  from orion.testing import OrionState
label_desc: Use image node_id 2 for calling the TestReportResults obj's underlying member method code with example usage: obj.test_with_correct_env(monkeypatch, capsys, tmpdir, data) without return types