Skip to content

Instantly share code, notes, and snippets.

@wrobstory
Created March 17, 2015 23:13
Show Gist options
  • Save wrobstory/bc7636e3254ca733f2d8 to your computer and use it in GitHub Desktop.
Save wrobstory/bc7636e3254ca733f2d8 to your computer and use it in GitHub Desktop.
Py.test Fixture error
import pytest
def setup_function(function):
foo = 1
function(foo)
def test_thing(thing):
two = thing + 1
assert two == 2
(.env)Robs-MacBook-Pro:tests robstory$ py.test fixtures.py
====================================================================================================== test session starts =======================================================================================================
platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.6.4
collected 1 items
fixtures.py E
============================================================================================================= ERRORS =============================================================================================================
__________________________________________________________________________________________________ ERROR at setup of test_thing __________________________________________________________________________________________________
file /Users/robstory/simple/data101/tests/fixtures.py, line 7
def test_thing(thing):
fixture 'thing' not found
available fixtures: pytestconfig, recwarn, monkeypatch, capfd, capsys, tmpdir
use 'py.test --fixtures [testpath]' for help on them.
/Users/robstory/simple/data101/tests/fixtures.py:7
==================================================================================================== 1 error in 0.01 seconds =====================================================================================================
(.env)Robs-MacBook-Pro:tests robstory$
@jiffyclub
Copy link

import pytest

@pytest.fixture
def thing():
    return 1

def test_thing(thing):
    two = thing + 1
    assert two == 2

@wrobstory
Copy link
Author

crying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment