How to use otherfunc_multi method in Pytest

Best Python code snippet using pytest

Run Pytest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

failure_demo.py

Source: failure_demo.py Github

copy
1from py.test import raises
2import py
3
4def otherfunc(a,b):
5    assert a==b
6
7def somefunc(x,y):
8    otherfunc(x,y)
9
10def otherfunc_multi(a,b): 
11    assert (a == 
12            b) 
13
14class TestFailing(object):
15    def test_simple(self):
16        def f():
17            return 42
18        def g():
19            return 43
20
21        assert f() == g()
22
23    def test_simple_multiline(self):
24        otherfunc_multi(
25                  42,
26                  6*9)
27
28    def test_not(self):
29        def f():
30            return 42
31        assert not f()
32
33    def test_complex_error(self):
34        def f():
35            return 44
36        def g():
37            return 43
38        somefunc(f(), g())
39
40    def test_z1_unpack_error(self):
41        l = []
42        a,b  = l
43
44    def test_z2_type_error(self):
45        l = 3
46        a,b  = l
47
48    def test_startswith(self):
49        s = "123"
50        g = "456"
51        assert s.startswith(g)
52
53    def test_startswith_nested(self):
54        def f():
55            return "123"
56        def g():
57            return "456"
58        assert f().startswith(g())
59
60    def test_global_func(self):
61        assert isinstance(globf(42), float)
62
63    def test_instance(self):
64        self.x = 6*7
65        assert self.x != 42
66
67    def test_compare(self):
68        assert globf(10) < 5
69
70    def test_try_finally(self):
71        x = 1
72        try:
73            assert x == 0
74        finally:
75            x = 0
76
77    def test_raises(self):
78        s = 'qwe'
79        raises(TypeError, "int(s)")
80
81    def test_raises_doesnt(self):
82        raises(IOError, "int('3')")
83
84    def test_raise(self):
85        raise ValueError("demo error")
86
87    def test_tupleerror(self):
88        a,b = [1]
89
90    def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
91        l = [1,2,3]
92        print "l is", l
93        a,b = l.pop()
94
95    def test_some_error(self):
96        if namenotexi:
97            pass
98
99    def test_generator(self):
100        yield None
101
102    def func1(self):
103        assert 41 == 42
104
105    def test_generator2(self):
106        yield self.func1
107
108# thanks to Matthew Scott for this test
109def test_dynamic_compile_shows_nicely():
110    src = 'def foo():\n assert 1 == 0\n'
111    name = 'abc-123'
112    module = py.std.imp.new_module(name)
113    code = py.code.compile(src, name, 'exec')
114    exec code in module.__dict__
115    py.std.sys.modules[name] = module
116    module.foo()
117
118
119def globf(x):
120    return x+1
121
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with Pytest on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)