Best Python code snippet using pytest
test_pytester.py
Source:test_pytester.py
...57 assert 158 """)59 result = testdir.runpytest()60 result.assert_outcomes(passed=1)61def make_holder():62 class apiclass:63 def pytest_xyz(self, arg):64 "x"65 def pytest_xyz_noarg(self):66 "x"67 apimod = type(os)('api')68 def pytest_xyz(arg):69 "x"70 def pytest_xyz_noarg():71 "x"72 apimod.pytest_xyz = pytest_xyz73 apimod.pytest_xyz_noarg = pytest_xyz_noarg74 return apiclass, apimod75@pytest.mark.parametrize("holder", make_holder())76def test_hookrecorder_basic(holder):77 pm = PytestPluginManager()78 pm.addhooks(holder)79 rec = HookRecorder(pm)80 pm.hook.pytest_xyz(arg=123)81 call = rec.popcall("pytest_xyz")82 assert call.arg == 12383 assert call._name == "pytest_xyz"84 pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")85 pm.hook.pytest_xyz_noarg()86 call = rec.popcall("pytest_xyz_noarg")87 assert call._name == "pytest_xyz_noarg"88def test_makepyfile_unicode(testdir):89 global unichr...
micar.py
Source:micar.py
...25 - halfspace().rotateY(deg(90)).left(t)26 - cone(r1, r2, h)27 )28 29def make_holder(t):30 polyg_xseg = 4.531 polyg_yseg = 4.532 hold_t = t33 34 hold_fil = 335 hold_fil2 = 136 eey = 2.837 polyg = polygon([38 (polyg_xseg*0, polyg_yseg*0.5), 39 (polyg_xseg, polyg_yseg*0.5),40 (polyg_xseg*2, polyg_yseg),41 (polyg_xseg*4, polyg_yseg),42 (polyg_xseg*4, polyg_yseg*3.5),43 (polyg_xseg*2, polyg_yseg*3.5),44 (polyg_xseg*0, polyg_yseg*3),45 (polyg_xseg*(-1), polyg_yseg*2),46 (polyg_xseg*(-1), polyg_yseg*1),47 ]).left(polyg_xseg*3)48 49 polyg = fillet(polyg, hold_fil)50 51 m = fillet(polyg.extrude(hold_t), hold_fil2)52 m = m + mirrorYZ()(m)53 54 hh = polygon([(0,-4), (-2,2), (-12,6), (5,8), (5,-4)]).extrude(hold_t).right(polyg_xseg*4-5).fillet(hold_fil2)55 c = circle(r=hold_t / 3 * 2).rotateY(deg(90)).forw(polyg_yseg*3.5)56 path = interpolate([57 (3*polyg_xseg, polyg_yseg*eey),58 (0*polyg_xseg, polyg_yseg*3.5),59 (-3*polyg_xseg, polyg_yseg*eey)60 ])61 sph = sphere(hold_t / 3 * 2)62 det = pipe(c, path) + sph.translate(3*polyg_xseg, polyg_yseg*eey, 0) + sph.translate(-3*polyg_xseg, polyg_yseg*eey, 0)63 det = det.up(hold_t/2)64 m = m + det65 return m.rotateY(deg(90)).up(polyg_xseg*4).left(hold_t/2).forw(polyg_yseg*0.4 + 1.5)66def make_rebr(r, t, h, xblade, angle):67 rebr = cylinder(r=r, h=h) - cylinder(r=r-t, h=h)68 rebr = difference([69 rebr, 70 halfspace().rotateX(-deg(90)),71 halfspace().rotateY(deg(90)),72 halfspace().rotateY(-deg(90)-angle).right(xblade)73 ])74 return rebr75######PARAMETRES######76r1 = 33 / 277r2 = 38.5 / 278r3 = r2*1.5179h = 780base = make_body(con=(r1,r2,h), cil=(16,5), centrad=11.5, tooth=(54,0.8), forbolt=(27/2,1,deg(0)))81base_support = make_base_support(r1=r1, r2=r2, s=r3-r2, h=h, t=3/2)82holder = make_holder(t=3).forw(16.5)83rebr = make_rebr(r=r3, t=2, h=23, xblade=r2, angle=deg(30)).up(h)84######################85 86m = union([87 holder,88 base,89 base_support,90 rebr91])92m = unify(m)...
mill_holder.py
Source:mill_holder.py
1import cadquery as cq2def make_holder():3 base = cq.Workplane().rect(171,82).extrude(17)4 mid = cq.Workplane().rect(171-30,82).extrude(92)5 cylinder = base.faces('>Y').edges('<Z').workplane().center(0,60).tag('center').circle(60).extrude(-82)6 base = base.union(mid).union(cylinder)7 base = base.workplaneFromTagged('center').circle(50).cutThruAll()8 return base9holder = make_holder()...
Looking for an in-depth tutorial around pytest? LambdaTest covers the detailed pytest tutorial that has everything related to the pytest, from setting up the pytest framework to automation testing. Delve deeper into pytest testing by exploring advanced use cases like parallel testing, pytest fixtures, parameterization, executing multiple test cases from a single file, and more.
Skim our below pytest tutorial playlist to get started with automation testing using the pytest framework.
https://www.youtube.com/playlist?list=PLZMWkkQEwOPlcGgDmHl8KkXKeLF83XlrP
Get 100 minutes of automation test minutes FREE!!