Best Python code snippet using pandera_python
test_shape_convert.py
Source:test_shape_convert.py
...11 return x12 x = torch.rand(*shape_nchw)13 output = nchw2nlc2nchw(test_func, x)14 assert output.shape == torch.Size(shape_nchw)15 def test_func2(x, arg):16 assert x.shape == torch.Size(shape_nlc)17 assert arg == 10018 return x19 x = torch.rand(*shape_nchw)20 output = nchw2nlc2nchw(test_func2, x, arg=100)21 assert output.shape == torch.Size(shape_nchw)22 def test_func3(x):23 assert x.is_contiguous()24 assert x.shape == torch.Size(shape_nlc)25 return x26 x = torch.rand(*shape_nchw)27 output = nchw2nlc2nchw(test_func3, x, contiguous=True)28 assert output.shape == torch.Size(shape_nchw)29 assert output.is_contiguous()30def test_nlc2nchw2nlc():31 # Test nlc2nchw2nlc function32 shape_nchw = (4, 2, 5, 5)33 shape_nlc = (4, 25, 2)34 def test_func(x):35 assert x.shape == torch.Size(shape_nchw)36 return x37 x = torch.rand(*shape_nlc)38 output = nlc2nchw2nlc(test_func, x, shape_nchw[2:])39 assert output.shape == torch.Size(shape_nlc)40 def test_func2(x, arg):41 assert x.shape == torch.Size(shape_nchw)42 assert arg == 10043 return x44 x = torch.rand(*shape_nlc)45 output = nlc2nchw2nlc(test_func2, x, shape_nchw[2:], arg=100)46 assert output.shape == torch.Size(shape_nlc)47 def test_func3(x):48 assert x.is_contiguous()49 assert x.shape == torch.Size(shape_nchw)50 return x51 x = torch.rand(*shape_nlc)52 output = nlc2nchw2nlc(test_func3, x, shape_nchw[2:], contiguous=True)53 assert output.shape == torch.Size(shape_nlc)54 assert output.is_contiguous()...
test_command.py
Source:test_command.py
1# This file is part of the GOsa framework.2#3# http://gosa-project.org4#5# Copyright:6# (C) 2016 GONICUS GmbH, Germany, http://www.gonicus.de7#8# See the LICENSE file in the project's top-level directory for details.9import pytest10from unittest import TestCase, mock11from gosa.client.command import *12from gosa.common.components import Command13class TestModule(object):14 @Command()15 def test_func1(self, param):16 """ Documentation """17 return True18class TestModule2(object):19 @Command()20 def undocumented_func(self):21 return True22class ClientCommandTestCase(TestCase):23 def test_undocumented(self):24 with mock.patch.dict("gosa.client.command.PluginRegistry.modules", {'TestModule2': TestModule2}),\25 pytest.raises(Exception):26 ClientCommandRegistry()27 def test_commands(self):28 reg = PluginRegistry.getInstance("ClientCommandRegistry")29 with mock.patch("gosa.client.command.PluginRegistry.modules", new_callable=mock.PropertyMock, return_value={'TestModule':30 TestModule}):31 reg.register('test_func1', 'TestModule.test_func1', [], 'signature1', 'documentation1')32 reg.register('test_func2', 'TestModule.test_func2', [], 'signature2', 'documentation2')33 res = reg.getMethods()34 assert 'test_func1' in res35 assert 'test_func2' in res36 reg.unregister('test_func2')37 assert 'test_func1' in res38 assert 'test_func2' not in res39 with pytest.raises(CommandInvalid):40 reg.dispatch('test_func2')41 with mock.patch("gosa.client.command.PluginRegistry.modules", new_callable=mock.PropertyMock, return_value={'TestModule': TestModule()}):...
minList.py
Source:minList.py
...19 else:20 tmp+=new_list[i]21 end +=122 return new_list[:start],new_list[start:end+1],new_list[end+1:]23def test_func2(num_list):24 '''25 æ±æ°ç»ä¸æ大ååºåçä¹ç§¯ï¼ååºåå¿
é¡»è¿ç»26 '''27 l=len(num_list)28 left = 029 hasNone = 030 flag = 031 flag_left = 032 for i in range(l):33 if num_list[i]<0:34 hasNone = 135 if flag==0:36 left = i37 flag = 138 right = i39 if hasNone==0:40 return num_list,[],[]41 else:42 if left==right:43 return num_list[:left],num_list[left:left+1],num_list[left+1:]44 else:45 new_list = num_list[left:right+1]46 L,M,R = findClear(new_list)47 L = num_list[:left]+L48 R = R+num_list[right+1:]49 return L,M,R50print(test_func2(s0))51print(test_func2(s1))52print(test_func2(s2))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!