Best Python code snippet using fMBT_python
test_decorate.py
Source: test_decorate.py
1#!/usr/bin/env python2#3# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)4# Copyright (c) 1997-2016 California Institute of Technology.5# Copyright (c) 2016-2019 The Uncertainty Quantification Foundation.6# License: 3-clause BSD. The full license text is available at:7# - https://github.com/uqfoundation/pathos/blob/master/LICENSE8"""9demonstrates pickle/source failure cases with decorators/factories and pp10"""11def __wrap_nested(function, inner_function):12 def function_wrapper(x):13 _x = x[:]14 return function(inner_function(_x))15 return function_wrapper16def wrap_nested(inner_function):17 def dec(function):18 def function_wrapper(x):19 _x = x[:]20 return function(inner_function(_x))21 return function_wrapper22 return dec23class _wrap_nested(object):24 def __init__(self, inner_function):25 self._inner_function = inner_function26 def __call__(self, function):27 def function_wrapper(x):28 _x = x[:]29 return function(self._inner_function(_x))30 return function_wrapper31def add(*args):32 #from numpy import sum33 return sum(*args)34''' # FAILS to find 'add' (returns [None,None])35@wrap_nested(add)36def addabs(x):37 return abs(x)38'''39#addabs = __wrap_nested(abs, add) # ok40wrapadd = wrap_nested(add) # ok41#wrapadd = _wrap_nested(add) # HANGS42addabs = wrapadd(abs) # <required for the latter two above>43#'''44def test_wrap():45 x = [(-1,-2),(3,-4)]46 y = [3, 1]47 assert list(map(addabs, x)) == y48 from pathos.pools import ProcessPool as Pool49 assert Pool().map(addabs, x) == y50 from pathos.pools import ParallelPool as Pool51 assert Pool().map(addabs, x) == y52if __name__ == '__main__':53 from pathos.helpers import freeze_support54 freeze_support()...
Check out the latest blogs from LambdaTest on this topic:
Collecting and examining data from multiple sources can be a tedious process. The digital world is constantly evolving. To stay competitive in this fast-paced environment, businesses must frequently test their products and services. While it’s easy to collect raw data from multiple sources, it’s far more complex to interpret it properly.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
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!!