
import io

from octane import app as o_app


def test_help():
    out, err = io.BytesIO(), io.BytesIO()
    app = o_app.OctaneApp(stdin=io.BytesIO(), stdout=out, stderr=err)
    try:
        app.run(["--help"])
    except SystemExit as e:
        assert e.code == 0
    assert not err.getvalue()
    assert 'Could not' not in out.getvalue()


import io

import pytest

from octane import app as o_app


@pytest.fixture
def octane_app():
    return o_app.OctaneApp(stdin=io.BytesIO(), stdout=io.BytesIO(),
                           stderr=io.BytesIO())


def test_help(octane_app):
    try:
        octane_app.run(["--help"])
    except SystemExit as e:
        assert e.code == 0
    assert not octane_app.stderr.getvalue()
    assert 'Could not' not in octane_app.stdout.getvalue()

Refactor test to use cool py.test's fixture
Refactor test to use cool py.test's fixture

  
  import io
+ 
+ import pytest
  
  from octane import app as o_app
  
  
+ @pytest.fixture
+ def octane_app():
+     return o_app.OctaneApp(stdin=io.BytesIO(), stdout=io.BytesIO(),
+                            stderr=io.BytesIO())
+ 
+ 
- def test_help():
+ def test_help(octane_app):
-     out, err = io.BytesIO(), io.BytesIO()
-     app = o_app.OctaneApp(stdin=io.BytesIO(), stdout=out, stderr=err)
      try:
-         app.run(["--help"])
+         octane_app.run(["--help"])
      except SystemExit as e:
          assert e.code == 0
-     assert not err.getvalue()
+     assert not octane_app.stderr.getvalue()
-     assert 'Could not' not in out.getvalue()
+     assert 'Could not' not in octane_app.stdout.getvalue()
  
Refactor test to use cool py.test's fixture
## Code Before:

import io

from octane import app as o_app


def test_help():
    out, err = io.BytesIO(), io.BytesIO()
    app = o_app.OctaneApp(stdin=io.BytesIO(), stdout=out, stderr=err)
    try:
        app.run(["--help"])
    except SystemExit as e:
        assert e.code == 0
    assert not err.getvalue()
    assert 'Could not' not in out.getvalue()

## Instruction:
Refactor test to use cool py.test's fixture
## Code After:

import io

import pytest

from octane import app as o_app


@pytest.fixture
def octane_app():
    return o_app.OctaneApp(stdin=io.BytesIO(), stdout=io.BytesIO(),
                           stderr=io.BytesIO())


def test_help(octane_app):
    try:
        octane_app.run(["--help"])
    except SystemExit as e:
        assert e.code == 0
    assert not octane_app.stderr.getvalue()
    assert 'Could not' not in octane_app.stdout.getvalue()
