- New
pytest.mark.skip
mark, which unconditional skips marked tests. Thanks @MichaelAquilina for the complete PR (#1040). - Fix #680: the -s and -c options should now work under xdist;
Config.fromdictargs
now represents its input much more faithfully. Thanks to @bukzor for the complete PR.
This file contains 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
import pytest, sys | |
sys.exit(pytest.main()) |
This file contains 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
# original from: http://pythontesting.net/framework/pytest/pytest-expect-plugin-1 | |
import pytest | |
import inspect | |
import os.path | |
@pytest.fixture | |
def expect(request): | |
def do_expect(expr, msg=''): | |
if not expr: | |
_log_failure(request.node, msg) |
This file contains 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
from PIL import ImageChops, ImageDraw, Image | |
import pytest | |
import os | |
import py.path | |
import math | |
import operator | |
def rms_diff(im1, im2): | |
"""Calculate the root-mean-square difference between two images | |
Taken from: http://snipplr.com/view/757/compare-two-pil-images-in-python/ |
This file contains 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
from __future__ import unicode_literals | |
import weakref | |
from coilib50 import unittest | |
class Test(unittest.TestCase): | |
_TESTS = [] | |
def test_01(self): | |
Test._TESTS.append(weakref.ref(self)) |
This file contains 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
import os | |
import fnmatch | |
import sys | |
directory = sys.argv[1] | |
for root, dirs, names in os.walk(sys.argv[1]): | |
for name in names: | |
if fnmatch.fnmatch(name, 'pytest_*.py') and os.path.basename(root) == '_tests': | |
source = os.path.join(root, name) |
This file contains 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
import requests | |
auth = ('nicoddemus', 'XXXX') | |
for issue_id in xrange(1, 768+1): | |
url = 'https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/issues/{issue_id}/comments' | |
url = url.format(accountname='pytest-dev', repo_slug='pytest', issue_id=issue_id) | |
print '-' *10, issue_id | |
data = { | |
"content": "This issue has been moved to GitHub: https://github.com/pytest-dev/pytest/issues/{issue_id}".format(issue_id=issue_id), | |
} |
This file contains 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
import types | |
import unittest | |
from _pytest.unittest import TestCaseFunction | |
import pytest | |
class LoadTestsSuiteCollector(pytest.Collector): | |
def __init__(self, name, parent, suite): |
This file contains 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
# python 2 | |
def foo(**kwargs): | |
x = kwargs.pop('x', 10) | |
y = kwargs.pop('y', 'no value') | |
if kwargs: | |
raise TypeError('unknown keyword arguments: %s' % kwargs.keys()) | |
print x, y | |
This file contains 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
# Code typically replaced by _warnings | |
def warn(message, category=None, stacklevel=1): | |
"""Issue a warning, or maybe ignore it or raise an exception.""" | |
# Check if message is already a Warning object | |
if isinstance(message, Warning): | |
category = message.__class__ | |
# Check category argument | |
if category is None: | |
category = UserWarning | |
if not (isinstance(category, type) and issubclass(category, Warning)): |
OlderNewer