How to use classSetUp method in Testify

Best Python code snippet using Testify_python

test_setups.py

Source:test_setups.py Github

copy

Full Screen

1import io2import sys3import unittest4def resultFactory(*_):5 return unittest.TestResult()6class TestSetups(unittest.TestCase):7 def getRunner(self):8 return unittest.TextTestRunner(resultclass=resultFactory,9 stream=io.StringIO())10 def runTests(self, *cases):11 suite = unittest.TestSuite()12 for case in cases:13 tests = unittest.defaultTestLoader.loadTestsFromTestCase(case)14 suite.addTests(tests)15 runner = self.getRunner()16 # creating a nested suite exposes some potential bugs17 realSuite = unittest.TestSuite()18 realSuite.addTest(suite)19 # adding empty suites to the end exposes potential bugs20 suite.addTest(unittest.TestSuite())21 realSuite.addTest(unittest.TestSuite())22 return runner.run(realSuite)23 def test_setup_class(self):24 class Test(unittest.TestCase):25 setUpCalled = 026 @classmethod27 def setUpClass(cls):28 Test.setUpCalled += 129 unittest.TestCase.setUpClass()30 def test_one(self):31 pass32 def test_two(self):33 pass34 result = self.runTests(Test)35 self.assertEqual(Test.setUpCalled, 1)36 self.assertEqual(result.testsRun, 2)37 self.assertEqual(len(result.errors), 0)38 def test_teardown_class(self):39 class Test(unittest.TestCase):40 tearDownCalled = 041 @classmethod42 def tearDownClass(cls):43 Test.tearDownCalled += 144 unittest.TestCase.tearDownClass()45 def test_one(self):46 pass47 def test_two(self):48 pass49 result = self.runTests(Test)50 self.assertEqual(Test.tearDownCalled, 1)51 self.assertEqual(result.testsRun, 2)52 self.assertEqual(len(result.errors), 0)53 def test_teardown_class_two_classes(self):54 class Test(unittest.TestCase):55 tearDownCalled = 056 @classmethod57 def tearDownClass(cls):58 Test.tearDownCalled += 159 unittest.TestCase.tearDownClass()60 def test_one(self):61 pass62 def test_two(self):63 pass64 class Test2(unittest.TestCase):65 tearDownCalled = 066 @classmethod67 def tearDownClass(cls):68 Test2.tearDownCalled += 169 unittest.TestCase.tearDownClass()70 def test_one(self):71 pass72 def test_two(self):73 pass74 result = self.runTests(Test, Test2)75 self.assertEqual(Test.tearDownCalled, 1)76 self.assertEqual(Test2.tearDownCalled, 1)77 self.assertEqual(result.testsRun, 4)78 self.assertEqual(len(result.errors), 0)79 def test_error_in_setupclass(self):80 class BrokenTest(unittest.TestCase):81 @classmethod82 def setUpClass(cls):83 raise TypeError('foo')84 def test_one(self):85 pass86 def test_two(self):87 pass88 result = self.runTests(BrokenTest)89 self.assertEqual(result.testsRun, 0)90 self.assertEqual(len(result.errors), 1)91 error, _ = result.errors[0]92 self.assertEqual(str(error),93 'setUpClass (%s.%s)' % (__name__, BrokenTest.__qualname__))94 def test_error_in_teardown_class(self):95 class Test(unittest.TestCase):96 tornDown = 097 @classmethod98 def tearDownClass(cls):99 Test.tornDown += 1100 raise TypeError('foo')101 def test_one(self):102 pass103 def test_two(self):104 pass105 class Test2(unittest.TestCase):106 tornDown = 0107 @classmethod108 def tearDownClass(cls):109 Test2.tornDown += 1110 raise TypeError('foo')111 def test_one(self):112 pass113 def test_two(self):114 pass115 result = self.runTests(Test, Test2)116 self.assertEqual(result.testsRun, 4)117 self.assertEqual(len(result.errors), 2)118 self.assertEqual(Test.tornDown, 1)119 self.assertEqual(Test2.tornDown, 1)120 error, _ = result.errors[0]121 self.assertEqual(str(error),122 'tearDownClass (%s.%s)' % (__name__, Test.__qualname__))123 def test_class_not_torndown_when_setup_fails(self):124 class Test(unittest.TestCase):125 tornDown = False126 @classmethod127 def setUpClass(cls):128 raise TypeError129 @classmethod130 def tearDownClass(cls):131 Test.tornDown = True132 raise TypeError('foo')133 def test_one(self):134 pass135 self.runTests(Test)136 self.assertFalse(Test.tornDown)137 def test_class_not_setup_or_torndown_when_skipped(self):138 class Test(unittest.TestCase):139 classSetUp = False140 tornDown = False141 @classmethod142 def setUpClass(cls):143 Test.classSetUp = True144 @classmethod145 def tearDownClass(cls):146 Test.tornDown = True147 def test_one(self):148 pass149 Test = unittest.skip("hop")(Test)150 self.runTests(Test)151 self.assertFalse(Test.classSetUp)152 self.assertFalse(Test.tornDown)153 def test_setup_teardown_order_with_pathological_suite(self):154 results = []155 class Module1(object):156 @staticmethod157 def setUpModule():158 results.append('Module1.setUpModule')159 @staticmethod160 def tearDownModule():161 results.append('Module1.tearDownModule')162 class Module2(object):163 @staticmethod164 def setUpModule():165 results.append('Module2.setUpModule')166 @staticmethod167 def tearDownModule():168 results.append('Module2.tearDownModule')169 class Test1(unittest.TestCase):170 @classmethod171 def setUpClass(cls):172 results.append('setup 1')173 @classmethod174 def tearDownClass(cls):175 results.append('teardown 1')176 def testOne(self):177 results.append('Test1.testOne')178 def testTwo(self):179 results.append('Test1.testTwo')180 class Test2(unittest.TestCase):181 @classmethod182 def setUpClass(cls):183 results.append('setup 2')184 @classmethod185 def tearDownClass(cls):186 results.append('teardown 2')187 def testOne(self):188 results.append('Test2.testOne')189 def testTwo(self):190 results.append('Test2.testTwo')191 class Test3(unittest.TestCase):192 @classmethod193 def setUpClass(cls):194 results.append('setup 3')195 @classmethod196 def tearDownClass(cls):197 results.append('teardown 3')198 def testOne(self):199 results.append('Test3.testOne')200 def testTwo(self):201 results.append('Test3.testTwo')202 Test1.__module__ = Test2.__module__ = 'Module'203 Test3.__module__ = 'Module2'204 sys.modules['Module'] = Module1205 sys.modules['Module2'] = Module2206 first = unittest.TestSuite((Test1('testOne'),))207 second = unittest.TestSuite((Test1('testTwo'),))208 third = unittest.TestSuite((Test2('testOne'),))209 fourth = unittest.TestSuite((Test2('testTwo'),))210 fifth = unittest.TestSuite((Test3('testOne'),))211 sixth = unittest.TestSuite((Test3('testTwo'),))212 suite = unittest.TestSuite((first, second, third, fourth, fifth, sixth))213 runner = self.getRunner()214 result = runner.run(suite)215 self.assertEqual(result.testsRun, 6)216 self.assertEqual(len(result.errors), 0)217 self.assertEqual(results,218 ['Module1.setUpModule', 'setup 1',219 'Test1.testOne', 'Test1.testTwo', 'teardown 1',220 'setup 2', 'Test2.testOne', 'Test2.testTwo',221 'teardown 2', 'Module1.tearDownModule',222 'Module2.setUpModule', 'setup 3',223 'Test3.testOne', 'Test3.testTwo',224 'teardown 3', 'Module2.tearDownModule'])225 def test_setup_module(self):226 class Module(object):227 moduleSetup = 0228 @staticmethod229 def setUpModule():230 Module.moduleSetup += 1231 class Test(unittest.TestCase):232 def test_one(self):233 pass234 def test_two(self):235 pass236 Test.__module__ = 'Module'237 sys.modules['Module'] = Module238 result = self.runTests(Test)239 self.assertEqual(Module.moduleSetup, 1)240 self.assertEqual(result.testsRun, 2)241 self.assertEqual(len(result.errors), 0)242 def test_error_in_setup_module(self):243 class Module(object):244 moduleSetup = 0245 moduleTornDown = 0246 @staticmethod247 def setUpModule():248 Module.moduleSetup += 1249 raise TypeError('foo')250 @staticmethod251 def tearDownModule():252 Module.moduleTornDown += 1253 class Test(unittest.TestCase):254 classSetUp = False255 classTornDown = False256 @classmethod257 def setUpClass(cls):258 Test.classSetUp = True259 @classmethod260 def tearDownClass(cls):261 Test.classTornDown = True262 def test_one(self):263 pass264 def test_two(self):265 pass266 class Test2(unittest.TestCase):267 def test_one(self):268 pass269 def test_two(self):270 pass271 Test.__module__ = 'Module'272 Test2.__module__ = 'Module'273 sys.modules['Module'] = Module274 result = self.runTests(Test, Test2)275 self.assertEqual(Module.moduleSetup, 1)276 self.assertEqual(Module.moduleTornDown, 0)277 self.assertEqual(result.testsRun, 0)278 self.assertFalse(Test.classSetUp)279 self.assertFalse(Test.classTornDown)280 self.assertEqual(len(result.errors), 1)281 error, _ = result.errors[0]282 self.assertEqual(str(error), 'setUpModule (Module)')283 def test_testcase_with_missing_module(self):284 class Test(unittest.TestCase):285 def test_one(self):286 pass287 def test_two(self):288 pass289 Test.__module__ = 'Module'290 sys.modules.pop('Module', None)291 result = self.runTests(Test)292 self.assertEqual(result.testsRun, 2)293 def test_teardown_module(self):294 class Module(object):295 moduleTornDown = 0296 @staticmethod297 def tearDownModule():298 Module.moduleTornDown += 1299 class Test(unittest.TestCase):300 def test_one(self):301 pass302 def test_two(self):303 pass304 Test.__module__ = 'Module'305 sys.modules['Module'] = Module306 result = self.runTests(Test)307 self.assertEqual(Module.moduleTornDown, 1)308 self.assertEqual(result.testsRun, 2)309 self.assertEqual(len(result.errors), 0)310 def test_error_in_teardown_module(self):311 class Module(object):312 moduleTornDown = 0313 @staticmethod314 def tearDownModule():315 Module.moduleTornDown += 1316 raise TypeError('foo')317 class Test(unittest.TestCase):318 classSetUp = False319 classTornDown = False320 @classmethod321 def setUpClass(cls):322 Test.classSetUp = True323 @classmethod324 def tearDownClass(cls):325 Test.classTornDown = True326 def test_one(self):327 pass328 def test_two(self):329 pass330 class Test2(unittest.TestCase):331 def test_one(self):332 pass333 def test_two(self):334 pass335 Test.__module__ = 'Module'336 Test2.__module__ = 'Module'337 sys.modules['Module'] = Module338 result = self.runTests(Test, Test2)339 self.assertEqual(Module.moduleTornDown, 1)340 self.assertEqual(result.testsRun, 4)341 self.assertTrue(Test.classSetUp)342 self.assertTrue(Test.classTornDown)343 self.assertEqual(len(result.errors), 1)344 error, _ = result.errors[0]345 self.assertEqual(str(error), 'tearDownModule (Module)')346 def test_skiptest_in_setupclass(self):347 class Test(unittest.TestCase):348 @classmethod349 def setUpClass(cls):350 raise unittest.SkipTest('foo')351 def test_one(self):352 pass353 def test_two(self):354 pass355 result = self.runTests(Test)356 self.assertEqual(result.testsRun, 0)357 self.assertEqual(len(result.errors), 0)358 self.assertEqual(len(result.skipped), 1)359 skipped = result.skipped[0][0]360 self.assertEqual(str(skipped),361 'setUpClass (%s.%s)' % (__name__, Test.__qualname__))362 def test_skiptest_in_setupmodule(self):363 class Test(unittest.TestCase):364 def test_one(self):365 pass366 def test_two(self):367 pass368 class Module(object):369 @staticmethod370 def setUpModule():371 raise unittest.SkipTest('foo')372 Test.__module__ = 'Module'373 sys.modules['Module'] = Module374 result = self.runTests(Test)375 self.assertEqual(result.testsRun, 0)376 self.assertEqual(len(result.errors), 0)377 self.assertEqual(len(result.skipped), 1)378 skipped = result.skipped[0][0]379 self.assertEqual(str(skipped), 'setUpModule (Module)')380 def test_suite_debug_executes_setups_and_teardowns(self):381 ordering = []382 class Module(object):383 @staticmethod384 def setUpModule():385 ordering.append('setUpModule')386 @staticmethod387 def tearDownModule():388 ordering.append('tearDownModule')389 class Test(unittest.TestCase):390 @classmethod391 def setUpClass(cls):392 ordering.append('setUpClass')393 @classmethod394 def tearDownClass(cls):395 ordering.append('tearDownClass')396 def test_something(self):397 ordering.append('test_something')398 Test.__module__ = 'Module'399 sys.modules['Module'] = Module400 suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)401 suite.debug()402 expectedOrder = ['setUpModule', 'setUpClass', 'test_something', 'tearDownClass', 'tearDownModule']403 self.assertEqual(ordering, expectedOrder)404 def test_suite_debug_propagates_exceptions(self):405 class Module(object):406 @staticmethod407 def setUpModule():408 if phase == 0:409 raise Exception('setUpModule')410 @staticmethod411 def tearDownModule():412 if phase == 1:413 raise Exception('tearDownModule')414 class Test(unittest.TestCase):415 @classmethod416 def setUpClass(cls):417 if phase == 2:418 raise Exception('setUpClass')419 @classmethod420 def tearDownClass(cls):421 if phase == 3:422 raise Exception('tearDownClass')423 def test_something(self):424 if phase == 4:425 raise Exception('test_something')426 Test.__module__ = 'Module'427 sys.modules['Module'] = Module428 messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')429 for phase, msg in enumerate(messages):430 _suite = unittest.defaultTestLoader.loadTestsFromTestCase(Test)431 suite = unittest.TestSuite([_suite])432 with self.assertRaisesRegex(Exception, msg):433 suite.debug()434if __name__ == '__main__':...

Full Screen

Full Screen

views.py

Source:views.py Github

copy

Full Screen

1from django.views.decorators.csrf import csrf_protect, csrf_exempt2from django.contrib import messages3from django.shortcuts import render, redirect4import re5from .forms import*6from django.views.generic import ListView, CreateView, UpdateView, DeleteView7from .models import*8app_name = 'smsapp'9class SectionView(ListView):10 model = Standard11 context_object_name = 'sections'12 template_name = 'smsapp/section_view.html'13class SectionDelete(DeleteView):14 model = Standard15def get_verbose_name(model_name):16 verbose_name_list = []17 for f in model_name._meta.get_fields():18 if hasattr(f, 'verbose_name' ):19 verbose_name_list.append( f.verbose_name )20 return verbose_name_list21def camel_case_split(CamelCaseStr):22 strlist = re.findall( r'[A-Z](?:[a-z]+|[A-Z]*(?=[A-Z]|$))', CamelCaseStr )23 class_name = ""24 lower_class_name = ""25 for item in strlist:26 class_name += " " + item27 lower_class_name += item.lower() + "_"28 return class_name, lower_class_name29def get_class_name(model_name):30 return camel_case_split( model_name.__name__ )31def get_class_fields(model_name):32 return [f.get_attname() for f in model_name._meta.fields]33# Create your views here.34def index(request):35 return render( request, 'smsapp/base.html' )36def admin_setting(request):37 return render( request, 'smsapp/admin_setting.html' )38# CRUD Operation Class Model39def class_setup_add_edit(request, id=0):40 if request.method == "GET":41 if id == 0:42 form = ClassSetupForm()43 else:44 obj = ClassSetup.objects.get( pk=id )45 form = ClassSetupForm( instance=obj )46 return render( request, 'smsapp/class_setup_add_edit.html',47 {"form": form} )48 else:49 if id == 0:50 form = ClassSetupForm(request.POST )51 52 else:53 obj = ClassSetup.objects.get( pk=id )54 form = ClassSetupForm( request.POST, instance=obj )55 56 if form.is_valid():57 form.save()58 messages.info( request, "Data saved Sucessfully!" )59 else:60 messages.warning( request, "Data is not saved!" )61 return redirect( 'smsapp:class_summary' )62def class_setup_view(request):63 verbose_names = get_verbose_name( ClassSetup )64 context = {'view_list': ClassSetup.objects.all(),65 'verbose_names': verbose_names}66 return render( request, 'smsapp/class_setup_view.html', context )67def class_setup_delete(request, id):68 obj = ClassSetup.objects.get( pk=id )69 obj.delete()70 messages.success( request, "Data deleted Sucessfully!" )71 return redirect( 'smsapp:class_summary' )72# CRUD Operation Section Model73def section_add_edit(request, id=0):74 if request.method == "GET":75 if id == 0:76 form = SectionForm()77 else:78 obj = Section.objects.get( pk=id )79 form = SectionForm( instance=obj )80 return render( request,81 'smsapp/section_add.html',82 {"form": form} )83 else:84 if id == 0:85 form = SectionForm( request.POST )86 else:87 obj = Section.objects.get( pk=id )88 form = SectionForm( request.POST, instance=obj )89 if form.is_valid():90 form.save()91 messages.success( request, "Data Added Successfully!" )92 return redirect( 'smsapp:section_view' )93def section_add(request):94 template_name = 'smsapp/section_add.html'95 if request.method == 'GET':96 form = StandardForm(request.GET or None)97 formset = SectionFormset(queryset=Section.objects.none())98 elif request.method == 'POST':99 form = StandardForm(request.POST)100 formset = SectionFormset(request.POST)101 if form.is_valid() and formset.is_valid():102 # first save this book, as its reference will be used in `Author`103 standard = form.save()104 for f in formset:105 print(f)106 print('i')107 # so that `book` instance can be attached.108 section = f.save(commit=False)109 section.standard_name = standard110 section.save()111 return redirect('smsapp:section_view')112 return render(request, template_name, {113 'form': form,114 'formset': formset,115 })116# def section_delete(request, id):117# obj = Section.objects.get( pk=id )118# obj.delete()119# messages.warning( request, "Data Deleted Successfully!" )120# return redirect( 'smsapp:section_view' )121# CRUD Operation Teacher Model122def teacher_add_edit(request, id=0):123 if request.method == "GET":124 if id == 0:125 form = TeacherForm()126 else:127 obj = Teacher.objects.get( pk=id )128 form = TeacherForm( instance=obj )129 return render( request, 'smsapp/teacher_add_edit.html', {"form": form} )130 else:131 if id == 0:132 form = TeacherForm( request.POST )133 else:134 obj = Teacher.objects.get( pk=id )135 form = TeacherForm( request.POST, instance=obj )136 if form.is_valid():137 form.save()138 messages.success( request, "Data Added Successfully!" )139 return redirect( 'smsapp:teacher_view' )140def teacher_view(request):141 class_name, lower_class_name = get_class_name( Teacher )142 verbose_name = get_verbose_name( Teacher )143 field_names = get_class_fields( Teacher )144 # print(field_names)145 view_list = Teacher.objects.all()146 context = {'view_list': view_list,147 'verbose_names': verbose_name,148 'class_name': class_name,149 'lower_class_name': lower_class_name150 }151 return render( request, 'smsapp/teacher_view.html', context )152def teacher_delete(request, id):153 obj = Teacher.objects.get( pk=id )154 obj.delete()155 messages.warning( request, "Data Deleted Successfully!" )156 return redirect( 'smsapp:teacher_view' )157# CRUD Operation student Model158def student_add_edit(request, id=0):159 if request.method == "GET":160 if id == 0:161 form = StudentForm()162 else:163 obj = Student.objects.get( pk=id )164 form = StudentForm( instance=obj )165 return render( request, 'smsapp/student_add_edit.html', {"form": form} )166 else:167 if id == 0:168 form = StudentForm( request.POST )169 print("I am at Post")170 else:171 obj = Student.objects.get( pk=id )172 form = StudentForm( request.POST, instance=obj )173 print(form.is_valid())174 if form.is_valid():175 form.save()176 messages.success( request, "Data Added Successfully!" )177 else:178 messages.warning( request, "Failed to Add Data!" )179 return redirect( 'smsapp:student_view' )180def student_view(request):181 class_name, lower_class_name = get_class_name( Student )182 verbose_name = get_verbose_name( Student )183 field_names = get_class_fields( Student )184 # print(field_names)185 view_list = Student.objects.all()186 context = {'view_list': view_list,187 'verbose_names': verbose_name,188 'class_name': class_name,189 'lower_class_name': lower_class_name190 }191 return render( request, 'smsapp/student_view.html', context )192def student_delete(request, id):193 obj = Student.objects.get( pk=id )194 obj.delete()195 messages.warning( request, "Data Deleted Successfully!" )196 return redirect( 'smsapp:student_view' )197# CRUD Operation subject Model198def subject_add_edit(request, id=0):199 if request.method == "GET":200 if id == 0:201 form = SubjectForm()202 else:203 obj = Subject.objects.get( pk=id )204 form = SubjectForm( instance=obj )205 return render( request,206 'smsapp/subject_add_edit.html',207 {"form": form} )208 else:209 if id == 0:210 form = SubjectForm( request.POST )211 else:212 obj = Subject.objects.get( pk=id )213 form = SubjectForm( request.POST, instance=obj )214 if form.is_valid():215 form.save()216 messages.success( request, "Data Added Successfully!" )217 return redirect( 'smsapp:subject_view' )218def subject_view(request):219 class_name, lower_class_name = get_class_name( Subject )220 verbose_name = get_verbose_name( Subject )221 field_names = get_class_fields( Subject )222 # print(field_names)223 view_list = Subject.objects.all()224 context = {'view_list': view_list,225 'verbose_names': verbose_name,226 'class_name': class_name,227 'lower_class_name': lower_class_name228 }229 return render( request, 'smsapp/subject_view.html',230 context )231def subject_delete(request, id):232 obj = Subject.objects.get( pk=id )233 obj.delete()234 messages.warning( request, "Data Deleted Successfully!" )235 return redirect( 'smsapp:subject_view' )236@csrf_exempt237def class_setup_add_edit_new(request, id=0):238 #tasks = request.POST.getlist('tasks')239 #print(tasks)240 if request.method == "GET":241 if id == 0:242 form = ClassSetupFormNew()243 else:244 obj = ClassSetup.objects.get( pk=id )245 form = ClassSetupFormNew( instance=obj )246 #print(form.teacher_name)247 return render( request, 'smsapp/class_setup_add_edit_new.html',248 {"form": form} )249 else:250 if id == 0:251 #form = ClassSetupFormNew(request.POST )252 form = ClassSetupFormset(request.POST)253 254 else:255 obj = ClassSetup.objects.get( pk=id )256 #form = ClassSetupFormNew( request.POST, instance=obj )257 258 if form.is_valid():259 for f in form:260 print(f.cleaned_data)261 #print(form.is_valid())262 print('I am going to save multiple data')263 #print(form.cleaned_data)264 form.save()265 messages.info( request, "Data saved Sucessfully in newclass setup !" )266 else:267 messages.warning( request, "Data is not saved in newclass setup!" )268 return redirect( 'smsapp:class_summary' )269def class_summary(request):270 verbose_names = get_verbose_name( ClassSetup )271 272 view_list_obj = ClassSetup.objects.all()273 class_id =list(set(sorted([item.class_name_id for item in view_list_obj])))274 class_list = list(set([str(item.class_name) for item in view_list_obj])) 275 276 def get_section_list(id):277 section_obj = ClassSetup.objects.filter(class_name_id = id)278 sec_list=[str(item_section.section_name) for item_section in section_obj] 279 return sec_list280 section_list= [get_section_list(id = item) for item in class_id]281 282 #print(class_list)283 #print(section_list)284 # context = {'view_list': ClassSetup.objects.all(),'verbose_names': verbose_names}285 context = {'view_list': ClassSetup.objects.all(),286 'class_list': class_list,287 'section_list': section_list,288 'verbose_names': verbose_names,289 290 }291 return render( request, 'smsapp/class_summary.html', context )292# for drop down selection293def dropdown_section_class_setup(request):294 class_name_id = request.GET.get('class_name' )295 forms = Section.objects.filter(standard_name_id=class_name_id )296 return render( request, 'smsapp/section_dropdown_class_setup.html', {'forms': forms})297@csrf_exempt298def dropdown_subject_class_setup(request):299 class_name_id = request.GET.get('class_name' )300 forms = Subject.objects.filter(class_name_id=class_name_id )301 return render( request, 'smsapp/subject_dropdown_class_setup.html', {'forms': forms})302def dropdown_teacher_class_setup(request):303 subject_name_id = request.GET.get('subject_name' )304 forms = Teacher.objects.filter(teaching_subjects=subject_name_id )305 return render( request, 'smsapp/teacher_dropdown_class_setup.html', {'forms': forms})306def dropdown_section_student(request):307 current_class_id = request.GET.get('current_class')308 forms = Section.objects.filter(standard_name_id=current_class_id )...

Full Screen

Full Screen

attr.py

Source:attr.py Github

copy

Full Screen

...5 minipyt_shared = True6 n = 07 def __init__(self):8 print("init works")9 def classSetUp(self):10 print("classSetUp")11 self.class_tda['classSetUp'] = 'class setup'12 self.class_tra['classSetUp'] = 'class setup'13 def setUp(self):14 print("setUp")15 self.class_tda['setUp'] = 'setup'16 self.class_tra['setUp'] = 'setup'17 def test_1(self):18 print("test_1")19 self.tda['test'] = 'test_1'20 self.tra['test'] = 'test_1'21 self.n = self.n + 122 self.tra['n'] = self.n23 def test_2(self):24 print("test_2")25 self.tda['test2'] = 'test_2'26 self.tra['test2'] = 'test_2'27 self.n = self.n + 128 self.tra['n'] = self.n29 def tearDown(self):30 print("tearDown")31 self.class_tda['tearDown'] = 'teardown'32 def classTearDown(self):33 print("class tearDown")34 self.class_tda['classTearDown'] = 'class teardown'35class not_shared(object):36 __test__ = True37 minipyt_shared = False38 n = 039 def __init__(self):40 print("init works")41 def classSetUp(self):42 print("classSetUp")43 self.class_tda['classSetUp'] = 'class setup'44 self.class_tra['classSetUp'] = 'class setup'45 def setUp(self):46 print("setUp")47 self.class_tda['setUp'] = 'setup'48 self.class_tra['setUp'] = 'setup'49 def test_1(self):50 print("test_1")51 self.tda['test'] = 'test_1'52 self.tra['test'] = 'test_1'53 self.n = self.n + 154 self.tra['n'] = self.n55 def test_2(self):56 print("test_2")57 self.tda['test'] = 'test_2'58 self.tra['test'] = 'test_2'59 self.n = self.n + 160 self.tra['n'] = self.n61 def tearDown(self):62 print("tearDown")63 self.class_tda['tearDown'] = 'teardown'64 def classTearDown(self):65 print("class tearDown")66 # class teardown cannot set attributes on class if the class is not67 # shared68class class_setup_exception(object):69 __test__ = True70 minipyt_shared = True71 def __init__(self):72 print("init class_setup_exception")73 def classSetUp(self):74 print("classSetUp")75 self.class_tda['classSetUp'] = 'class setup'76 raise Exception('ARF')77 def setUp(self):78 print("setUp")79 self.class_tda['setUp'] = 'setup'80 def test_1(self):81 print("test_1")82 self.tda['test'] = 'test_1'83 self.tra['test'] = 'test_1'84 def test_2(self):85 print("test_2")86 self.tda['test'] = 'test_2'87 self.tra['test'] = 'test_2'88 def tearDown(self):89 print("tearDown")90 self.class_tda['tearDown'] = 'teardown'91 def classTearDown(self):92 print("class tearDown")93 self.class_tda['classTearDown'] = 'class teardown'94class setup_exception(object):95 __test__ = True96 minipyt_shared = True97 def __init__(self):98 print("init setup_exception")99 def classSetUp(self):100 print("classSetUp")101 self.class_tda['classSetUp'] = 'class setup'102 def setUp(self):103 print("setUp")104 self.class_tda['setUp'] = 'setup'105 raise Exception('ARF')106 def test_1(self):107 print("test_1")108 self.tda['test'] = 'test_1'109 self.tra['test'] = 'test_1'110 def test_2(self):111 print("test_2")112 self.tda['test2'] = 'test_2'113 self.tra['test2'] = 'test_2'...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testify automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful