
from os.path import join

from platformio.commands.test import cli as cli_test


def test_local_env(clirunner, validate_cliresult):
    result = clirunner.invoke(
        cli_test,
        ["-d", join("examples", "unit-testing", "calculator"), "-e", "local"])
    validate_cliresult(result)
    assert all(
        [s in result.output for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])


from os.path import join

import pytest

from platformio import util


def test_local_env():
    result = util.exec_command(["platformio", "test", "-d",
                                join("examples", "unit-testing", "calculator"),
                                "-e", "local"])
    if result['returncode'] != 0:
        pytest.fail(result)
    assert all(
        [s in result['out'] for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])

Fix test for "pio test"
Fix test for "pio test"

  
  from os.path import join
  
- from platformio.commands.test import cli as cli_test
+ import pytest
+ 
+ from platformio import util
  
  
- def test_local_env(clirunner, validate_cliresult):
-     result = clirunner.invoke(
-         cli_test,
-         ["-d", join("examples", "unit-testing", "calculator"), "-e", "local"])
-     validate_cliresult(result)
+ def test_local_env():
+     result = util.exec_command(["platformio", "test", "-d",
+                                 join("examples", "unit-testing", "calculator"),
+                                 "-e", "local"])
+     if result['returncode'] != 0:
+         pytest.fail(result)
      assert all(
-         [s in result.output for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])
+         [s in result['out'] for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])
  
Fix test for "pio test"
## Code Before:

from os.path import join

from platformio.commands.test import cli as cli_test


def test_local_env(clirunner, validate_cliresult):
    result = clirunner.invoke(
        cli_test,
        ["-d", join("examples", "unit-testing", "calculator"), "-e", "local"])
    validate_cliresult(result)
    assert all(
        [s in result.output for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])

## Instruction:
Fix test for "pio test"
## Code After:

from os.path import join

import pytest

from platformio import util


def test_local_env():
    result = util.exec_command(["platformio", "test", "-d",
                                join("examples", "unit-testing", "calculator"),
                                "-e", "local"])
    if result['returncode'] != 0:
        pytest.fail(result)
    assert all(
        [s in result['out'] for s in ("[PASSED]", "[IGNORED]", "[FAILED]")])
