Skip to content
View customtestids.py
import pytest
def params(n):
fn = range(n)
return {'name': 'a', 'args': fn, 'ids': ['a: {}'.format(i) for i in fn]}
named_args = params(3)
@pytest.mark.parametrize(
named_args['name'], named_args['args'], ids=named_args['ids'])
View issue4806.py
# written in python2.7
def bad(n):
if n == 1:
raise ValueError('n is 1!')
if n == 2:
raise TypeError('n is 2!')
return n, 2*n
View memes.pl
% Generate/verify memes in Prolog.
noun(apple).
noun(banana).
noun(orange).
noun(kiwifruit).
irregular_noun(kiwifruit, kiwifruit).
View 2.3.5_before.py
import pytest
@pytest.mark.parametrize("input", "expected", [
("3+5", 8),
("2+4", 6),
])
def test_evalPassing(input, expected):
assert eval(input) == expected
View trickysorting.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View embeddinghtml.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View conftest.py
def pytest_generate_tests(metafunc):
"""
If the test_ fn has a idparametrize mark, use it to create parametrized
tests with ids. Instead of giving a list of argvals (test values), it
should be a dict of test id strings -> tuple of test values
e.g.
@py.test.mark.idparametrize(('a', 'b'), {
'foo': (1, 2),
'bar': (3, 4),
})
View progressive.py
"""Public domain, yo.
See http://brianna.laugher.id.au/blog/79/the-progressive-speaking-stack-in-python for background.
"""
class Speaker:
def __init__(self, name):
self.name = name
self._hasSpoken = False
def __eq__(self, other):
View adb logcat output
I/dalvikvm( 1836): Failed resolving Lorg/thoughtcrime/securesms/ConversationListFragment$1; interface 573 'Landroid/widget/SearchView$OnQueryTextListener;'
W/dalvikvm( 1836): Link of class 'Lorg/thoughtcrime/securesms/ConversationListFragment$1;' failed
E/dalvikvm( 1836): Could not find class 'org.thoughtcrime.securesms.ConversationListFragment$1', referenced from method org.thoughtcrime.securesms.ConversationListFragment.initializeSearch
W/dalvikvm( 1836): VFY: unable to resolve new-instance 1205 (Lorg/thoughtcrime/securesms/ConversationListFragment$1;) in Lorg/thoughtcrime/securesms/ConversationListFragment;
D/dalvikvm( 1836): VFY: replacing opcode 0x22 at 0x0000
D/dalvikvm( 1836): VFY: dead code 0x0002-0008 in Lorg/thoughtcrime/securesms/ConversationListFragment;.initializeSearch (Landroid/widget/SearchView;)V
E/dalvikvm( 1836): Could not find class 'android.widget.SearchView', referenced from method org.thoughtcrime.securesms.ConversationListFragment.onPrepareOptionsMenu
W/dalvikvm( 1836): VFY: unable to
View 00-intro_errorreporting.txt
These are snippets of py.test in action, used in a talk given at
PyCon AU 2012 in Hobart, Tasmania. They are all relevant for
py.test 2.2 except where specified. Where taken from open source
projects I have listed a URL, some examples are from the py.test
documentation, some are from my workplace.
Apart from things called test_*, these functions should probably
be in your conftest.py, although they can generally start life in
your test files.
Something went wrong with that request. Please try again.