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
# content of conftest.py | |
import pytest | |
@pytest.mark.tryfirst | |
def pytest_pyfunc_call(pyfuncitem): | |
marker = pyfuncitem.get_marker("skip_if_eval") | |
if marker is not None: | |
class Mapping: | |
def __getitem__(self, name): |
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
location ~ \+f/ { | |
try_files $uri @proxy_to_app; | |
} | |
location ~ \+doc/ { | |
try_files $uri @proxy_to_app; | |
} | |
location / { | |
proxy_pass http://localhost:3141; | |
proxy_set_header X-outside-url $scheme://$host; | |
proxy_set_header X-Real-IP $remote_addr; |
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
class TestGitHubAPI: | |
def test_user(self, vcr): | |
vcr.use_cassette('user') | |
resp = self.session.get('https://api.github.com/user', | |
auth=('user', 'pass')) | |
assert resp.json()['login'] is not None | |
@betamax_cassette("repo") | |
def test_repo(self): | |
resp = self.session.get( |
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
etamax_cassette = pytest.mark.betamax_cassette | |
class TestGitHubAPI: | |
def test_user(self, session, vcr): | |
vcr.use_cassette('user') | |
resp = session.get('https://api.github.com/user', | |
auth=('user', 'pass')) | |
assert resp.json()['login'] is not None |
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
import pytest | |
with pytest.FixtureContext("db", path="...") as db: | |
# work with db | |
any finalizers will be called at the end of the with statement |
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
import pytest | |
def test_hello(tmpdir): | |
print "hello using", tmpdir | |
assert 0 | |
if __name__ == "__main__": | |
pytest.main(["--pyargs", "x"]) |
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
(0)hpk@teta:~/p/pytest$ cat test_x.py | |
def test_assert(): | |
x = 3 | |
assert x == 4 | |
(0)hpk@teta:~/p/pytest$ python -OO -m pytest test_x.py | |
WARNING: assertions which are not in test modules will be ignored because assert statements are not executed by the underlying Python interpreter (are you using python -O?) | |
============================= test session starts ============================== | |
platform linux2 -- Python 2.7.3 -- pytest-2.4.3.dev2 |
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
import execnet | |
def execnet_main(channel): | |
import inspect | |
import sys | |
f = sys._getframe() | |
frames = [] | |
while f: |
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
import pytest | |
import mock | |
@mock.patch("os.path.abspath") | |
def test_one(mock_abspath): | |
pass | |
@mock.patch("os.path.abspath") | |
def test_two(mock_abspath): | |
pass |
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
(py33)hpk@teta:/tmp/test_gen0$ python mypytest.py -n1 test_x.py | |
============================= test session starts ============================== | |
platform linux -- Python 3.3.2 -- pytest-2.4.3.dev2 | |
plugins: xdist, instafail, capturelog, cache | |
gw0 C[gw0] node down: Traceback (most recent call last): | |
File "/home/hpk/venv/py33/local/lib/python3.3/site-packages/execnet/gateway_base.py", line 800, in executetask | |
do_exec(co, loc) | |
File "<string>", line 1, in do_exec | |
File "<remote exec>", line 139, in <module> | |
File "<remote exec>", line 117, in remote_initconfig |