How to use somefunc method in Nose

Best Python code snippet using nose

test_appinterp.py

Source:test_appinterp.py Github

copy

Full Screen

...52 """)53 assert app.func_name == 'app'54 w_result = app(space) 55 assert space.eq_w(w_result, space.wrap(42))56def somefunc(arg2=42): 57 return arg2 58def test_app2interp_somefunc(space): 59 app = appdef(somefunc) 60 w_result = app(space) 61 assert space.eq_w(w_result, space.wrap(42))62def test_applevel_functions(space, applevel_temp = applevel_temp):63 app = applevel_temp('''64 def f(x, y):65 return x-y66 def g(x, y):67 return f(y, x)68 ''')69 g = app.interphook('g')70 w_res = g(space, space.wrap(10), space.wrap(1))71 assert space.eq_w(w_res, space.wrap(-9))72def test_applevel_class(space, applevel_temp = applevel_temp):73 app = applevel_temp('''74 class C(object):75 clsattr = 42 76 def __init__(self, x=13): 77 self.attr = x 78 ''')79 C = app.interphook('C')80 c = C(space, space.wrap(17)) 81 w_attr = space.getattr(c, space.wrap('clsattr'))82 assert space.eq_w(w_attr, space.wrap(42))83 w_clsattr = space.getattr(c, space.wrap('attr'))84 assert space.eq_w(w_clsattr, space.wrap(17))85def app_test_something_at_app_level(): 86 x = 287 assert x/2 == 188class AppTestMethods: 89 def test_some_app_test_method(self): 90 assert 2 == 291class TestMixedModule: 92 def test_accesses(self): 93 space = self.space94 import demomixedmod 95 w_module = demomixedmod.Module(space, space.wrap('mixedmodule'))96 space.appexec([w_module], """97 (module): 98 assert module.value is None 99 assert module.__doc__ == 'mixedmodule doc'100 assert module.somefunc is module.somefunc 101 result = module.somefunc() 102 assert result == True 103 assert module.someappfunc is module.someappfunc 104 appresult = module.someappfunc(41) 105 assert appresult == 42 106 assert module.__dict__ is module.__dict__107 for name in ('somefunc', 'someappfunc', '__doc__', '__name__'): 108 assert name in module.__dict__109 """)110 assert space.is_true(w_module.call('somefunc'))111 def test_whacking_at_loaders(self):112 """Some MixedModules change 'self.loaders' in __init__(), but doing113 so they incorrectly mutated a class attribute. 'loaders' is now a114 per-instance attribute, holding a fresh copy of the dictionary.115 """...

Full Screen

Full Screen

test_Scheduler.py

Source:test_Scheduler.py Github

copy

Full Screen

...27from poseidon.poseidonMain.Scheduler.Scheduler import scheduler_interface28module_logger = logging.getLogger(__name__)29def test_instantiation():30 Scheduler()31def somefunc(jobId, logger):32 module_logger.info('someFunc: {0} {1}'.format(jobId, str(logger)))33 return True34def test_add():35 jobId = 'JOBID'36 jobId2 = 'JOBID2'37 s = scheduler_interface38 s.logger = module_logger39 s.logger.setLevel(logging.DEBUG)40 b = CRONSPEC(EVERY.minute, None)41 ostr = 'cronspec: {0}'.format(str(b))42 module_logger.debug(ostr)43 s.add_job(jobId, b, somefunc)44 s.add_job(jobId2, b, somefunc)45 s.schedule.run_all()...

Full Screen

Full Screen

rave_pgf_registry_test.py

Source:rave_pgf_registry_test.py Github

copy

Full Screen

1'''2Copyright (C) 2018 Swedish Meteorological and Hydrological Institute, SMHI,3This file is part of RAVE.4RAVE is free software: you can redistribute it and/or modify5it under the terms of the GNU Lesser General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.8RAVE is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU Lesser General Public License for more details.12You should have received a copy of the GNU Lesser General Public License13along with RAVE. If not, see <http://www.gnu.org/licenses/>.14------------------------------------------------------------------------*/15Tests the python version of the pgf registry xml handling16@file17@author Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)18@date 2018-03-1019'''20import unittest21import string22import os23import rave_pgf_registry24class rave_pgf_registry_test(unittest.TestCase):25 TEMPORARY_FILE="rave_pgf_registry_test.xml"26 27 def setUp(self):28 if os.path.isfile(self.TEMPORARY_FILE):29 os.unlink(self.TEMPORARY_FILE)30 def tearDown(self):31 if os.path.isfile(self.TEMPORARY_FILE):32 os.unlink(self.TEMPORARY_FILE)33 def testRead(self):34 txt = """<?xml version="1.0" encoding="UTF-8"?>35<generate-registry>36 <se.somefunc.1 function="generate" help="help text" module="rave_plugin">37 <arguments floats="zra,zrb" ints="a,b,c" strings="str" />38 </se.somefunc.1>39 <se.somefunc.2 function="generate2" help="help text2" module="rave_plugin2">40 <arguments floats="zraz,zrbz" ints="az,bz,cz" strings="strz" />41 </se.somefunc.2>42</generate-registry>43""" 44 self.writeTempFile(txt)45 46 classUnderTest = rave_pgf_registry.PGF_Registry()47 classUnderTest.read(self.TEMPORARY_FILE)48 self.assertEqual(txt, classUnderTest.tostring())49 50 el = classUnderTest.find("se.somefunc.1")51 self.assertTrue(el != None)52 self.assertEqual("generate", el.attrib["function"])53 self.assertEqual("rave_plugin", el.attrib["module"])54 self.assertEqual("help text", el.attrib["help"])55 self.assertEqual("zra,zrb", el[0].attrib["floats"])56 self.assertEqual("a,b,c", el[0].attrib["ints"])57 self.assertEqual("str", el[0].attrib["strings"])58 59 el = classUnderTest.find("se.somefunc.2")60 self.assertTrue(el != None)61 self.assertEqual("generate2", el.attrib["function"])62 self.assertEqual("rave_plugin2", el.attrib["module"])63 self.assertEqual("help text2", el.attrib["help"])64 self.assertEqual("zraz,zrbz", el[0].attrib["floats"])65 self.assertEqual("az,bz,cz", el[0].attrib["ints"])66 self.assertEqual("strz", el[0].attrib["strings"])67 68 def testRegister(self):69 txt = """<?xml version="1.0" encoding="UTF-8"?>70<generate-registry>71 <se.somefunc.1 function="generate" help="help text" module="rave_plugin">72 <arguments floats="zra,zrb" ints="a,b,c" strings="str" />73 </se.somefunc.1>74 <se.somefunc.2 function="generate2" help="help text2" module="rave_plugin2">75 <arguments floats="zraz,zrbz" ints="az,bz,cz" strings="strz" />76 </se.somefunc.2>77</generate-registry>78""" 79 expected = """<?xml version="1.0" encoding="UTF-8"?>80<generate-registry>81 <se.somefunc.1 function="generate" help="help text" module="rave_plugin">82 <arguments floats="zra,zrb" ints="a,b,c" strings="str" />83 </se.somefunc.1>84 <se.somefunc.2 function="generate2" help="help text2" module="rave_plugin2">85 <arguments floats="zraz,zrbz" ints="az,bz,cz" strings="strz" />86 </se.somefunc.2>87 <se.somefunc.3 function="generate3" help="help text3" module="rave_plugin3">88 <arguments floats="f1" ints="i1" strings="s1" />89 </se.somefunc.3>90</generate-registry>91""" 92 self.writeTempFile(txt)93 94 classUnderTest = rave_pgf_registry.PGF_Registry(filename=self.TEMPORARY_FILE)95 classUnderTest.register("se.somefunc.3", "rave_plugin3", "generate3", "help text3", "s1", "i1", "f1", "")96 with open(self.TEMPORARY_FILE) as fp:97 result = fp.read()98 99 self.assertEqual(expected, result)100 def writeTempFile(self, txt):101 if os.path.isfile(self.TEMPORARY_FILE):102 os.unlink(self.TEMPORARY_FILE)103 fp = open(self.TEMPORARY_FILE, "w")104 fp.write(txt)...

Full Screen

Full Screen

manager.py

Source:manager.py Github

copy

Full Screen

...5 def setUp(self):6 self.manager = BaseManager()7 def test_register_unregister_simple(self):8 @self.manager.register('item')9 def somefunc(some, args):10 return sum(some, args)11 self.assertIn(somefunc.__name__, self.manager._registered['item'])12 self.assertIn(somefunc, self.manager._registered['item'].values())13 with self.assertRaises(ValueError):14 self.manager.register('item', item=somefunc)15 self.manager.unregister('item', somefunc)16 self.assertNotIn(somefunc.__name__, self.manager._registered['item'])17 self.assertNotIn(somefunc, self.manager._registered['item'].values())18 def test_register_unregister_custom_name(self):19 @self.manager.register('item', name='test')20 def somefunc(some, args):21 return sum(some, args)22 self.assertIn('test', self.manager._registered['item'])23 self.assertIn(somefunc, self.manager._registered['item'].values())24 self.manager.unregister('item', 'test')25 self.assertNotIn('test', self.manager._registered['item'])26 self.assertNotIn(somefunc, self.manager._registered['item'].values())27 def test_register_unregister_inner(self):28 @self.manager.register('item', related='asd')29 def somefunc(some, args):30 return sum(some, args)31 @self.manager.register('item', name='other', related='asd')32 def someotherfunc(some, args):33 return sum(some, args)34 self.assertIn(35 somefunc.__name__, self.manager._registered['item']['asd'])36 self.assertIn(37 somefunc, self.manager._registered['item']['asd'].values())38 self.assertIn('other', self.manager._registered['item']['asd'])39 self.assertIn(40 someotherfunc, self.manager._registered['item']['asd'].values())41 self.assertEqual(42 somefunc, self.manager.get('item', 'somefunc', related='asd'))43 self.assertEqual(...

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 Nose 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