How to use the py.test function in py

To help you get started, we’ve selected a few py examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytest-dev / pytest / testing / test_conftesthandle.py View on Github external
@py.test.mark.multi(name='test tests whatever .dotdir'.split())
def test_setinitial_conftest_subdirs(testdir, name):
    sub = testdir.mkdir(name)
    subconftest = sub.ensure("conftest.py")
    conftest = Conftest()
    conftest.setinitial([sub.dirpath(), '--confcutdir=%s' % testdir.tmpdir])
    if name not in ('whatever', '.dotdir'):
        assert  subconftest in conftest._conftestpath2mod
        assert len(conftest._conftestpath2mod) == 1
    else:
        assert  subconftest not in conftest._conftestpath2mod
        assert len(conftest._conftestpath2mod) == 0
github tiddlyweb / tiddlyweb / test / test_web.py View on Github external
def test_missing_system_plugin():
    config['system_plugins'] = ['missingplugin']
    with py.test.raises(ImportError):
        serve.load_app()
    config['system_plugins'] = []
github mozillazg / pypy / extra_tests / cffi_tests / cffi1 / test_recompiler.py View on Github external
char32_t foo_4bytes(char32_t);
    """)
    lib = verify(ffi, "test_char16_char32_type" + no_cpp * "_nocpp", """
    #if !defined(__cplusplus) || (!defined(_LIBCPP_VERSION) && __cplusplus < 201103L)
    typedef uint_least16_t char16_t;
    typedef uint_least32_t char32_t;
    #endif

    char16_t foo_2bytes(char16_t a) { return (char16_t)(a + 42); }
    char32_t foo_4bytes(char32_t a) { return (char32_t)(a + 42); }
    """, no_cpp=no_cpp)
    assert lib.foo_2bytes(u+'\u1234') == u+'\u125e'
    assert lib.foo_4bytes(u+'\u1234') == u+'\u125e'
    assert lib.foo_4bytes(u+'\U00012345') == u+'\U0001236f'
    py.test.raises(TypeError, lib.foo_2bytes, u+'\U00012345')
    py.test.raises(TypeError, lib.foo_2bytes, 1234)
    py.test.raises(TypeError, lib.foo_4bytes, 1234)
github pytest-dev / pytest / testing / code / test_assertion.py View on Github external
def setup_class(cls):
        cls.View = py.test.importorskip("py._code._assertionold").View
github pytest-dev / pytest / py / apigen / testing / test_linker.py View on Github external
def test_check_incompatible():
    py.test.raises(ValueError, "relpath('/a', 'b')")
github tiddlyweb / tiddlyweb / test / test_store_user.py View on Github external
def test_simple_put():
    user = User('cdent', note='foo')
    user.set_password('cowpig')
    user.add_role('ADMIN')
    user.add_role('BOSS')
    store.put(user)

    if type(store.storage) != tiddlyweb.stores.text.Store:
        py.test.skip('skipping this test for non-text store')

    assert os.path.exists(expected_stored_filename)
github pytest-dev / pytest / py / execnet / testing / test_gwspec.py View on Github external
    @py.test.mark.xfail("implement socketserver test scenario")
    def test_socketgateway(self):
        gw = py.execnet.PopenGateway()
        spec = py.execnet.GatewaySpec("ssh:" + sshhost)
github pytest-dev / pytest / py / apigen / testing / test_apigen_functional.py View on Github external
def test_apigen_functional():
    #if py.std.sys.platform == "win32":
    #    py.test.skip("XXX test fails on windows")
    fs_root, package_name = setup_fs_project('test_apigen_functional')
    tempdir = py.test.ensuretemp('test_apigen_functional_results')
    pydir = py.magic.autopath().dirpath().dirpath().dirpath()
    pakdir = fs_root.join('pak')
    if py.std.sys.platform == 'win32':
        cmd = ('set APIGENPATH=%s && set PYTHONPATH=%s && '
               'python "%s/bin/py.test"') % (tempdir, fs_root, pydir)
    else:
        cmd = ('APIGENPATH="%s" PYTHONPATH="%s" '
               'python "%s/bin/py.test"') % (tempdir, fs_root, pydir)
    try:
        output = py.process.cmdexec('%s --apigen="%s/apigen.py" "%s"' % (
                                        cmd, fs_root, pakdir))
    except py.error.Error, e:
        print e.out
        raise
    assert output.lower().find('traceback') == -1
github holzschu / python3_ios / extraPackages / cffi-1.11.5 / testing / cffi1 / test_parse_c_type.py View on Github external
def parse_error(input, expected_msg, expected_location):
    e = py.test.raises(ParseError, parse, input)
    assert e.value.args[0] == expected_msg
    assert e.value.args[1] == expected_location
github pytest-dev / pytest / pytest / plugin / restdoc.py View on Github external
def restcheck(self, path):
        py.test.importorskip("docutils")
        self.register_linkrole()
        from docutils.utils import SystemMessage
        try:
            self._checkskip(path, self.project.get_htmloutputpath(path))
            self.project.process(path)
        except KeyboardInterrupt:
            raise
        except SystemMessage:
            # we assume docutils printed info on stdout
            py.test.fail("docutils processing failed, see captured stderr")