Created
April 20, 2017 14:54
-
-
Save arthuralvim/631e05bda85277531cad3af241b60fb6 to your computer and use it in GitHub Desktop.
Just a snippet for Pytest files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
import pytest | |
@pytest.mark.parametrize('input, expected', [ | |
('2 + 3', 5), | |
('6 - 4', 2), | |
pytest.mark.xfail(('5 + 2', 8)) | |
]) | |
def test_equations(input, expected): | |
"""Test that equation works""" | |
assert eval(input) == expected | |
def setup_module(module): | |
"""Run at the start of a testing module (module)""" | |
pass | |
def teardown_module(module): | |
"""Run at the end of a testing module (file)""" | |
pass | |
class TestPyTestClass(object): | |
@classmethod | |
def setup_class(cls): | |
"""Setup the class""" | |
pass | |
@classmethod | |
def teardown_class(cls): | |
"""Teardown the class""" | |
pass | |
def setup_method(method): | |
"""Setup a method""" | |
pass | |
def teardown_method(method): | |
"""Teardown a method""" | |
pass | |
@pytest.mark.parametrize('input, expected', [ | |
('2 + 3', 5), | |
('6 - 4', 2), | |
pytest.mark.xfail(('5 + 2', 8)) | |
]) | |
def test_equations(self, input, expected): | |
"""Test that equation works""" | |
assert eval(input) == expected | |
def setup_function(function): | |
"""Setup a function""" | |
pass | |
def teardown_function(function): | |
"""Teardown a function""" | |
pass | |
]]></content> | |
<tabTrigger>pytestfile</tabTrigger> | |
<scope>source.python</scope> | |
</snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment