### Install robotframework-gevent Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/README.md Install the library using pip. This is the first step to using robotframework-gevent in your projects. ```bash pip install robotframework-gevent ``` -------------------------------- ### Basic Gevent Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html A simple example demonstrating the use of gevent for asynchronous operations. This snippet shows how to monkey-patch standard library modules to make them gevent-compatible. ```python from gevent import monkey monkey.patch_all() import gevent import time def say(s): for i in xrange(5): print s, gevent.sleep(0.1) def runner(): gevent.spawn(say, 'hello') gevent.spawn(say, 'world') runner() ``` -------------------------------- ### Robot Framework Example Usage Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Demonstrates how to use the GeventLibrary in a Robot Framework test case to run keywords concurrently. ```robotframework ** Settings ** Library GeventLibrary ** Test Cases ** Test1 Log Hello World Create Gevent Bundle alias=alias1 Add Coroutine Sleep 1s alias=alias1 Add Coroutine Sleep 1s alias=alias1 ${values} Run Coroutines alias=alias1 Log Many @{values} ``` -------------------------------- ### Registering Animation Prefilters Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Allows registration of prefilters that run before an animation starts, useful for setup and special property handling. ```javascript S.Animation=S.extend(ft,{prefilters:[function(e,t,n){var r,i,o,a,s,u,l,c="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),v=Y.get(e,"fxshow");for(r in n.queue||(null==(a=S._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,S.queue(e,"fx").length||a.empty.fire()})})),t)if(i=t[r],ot.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}d[r]=v&&v[r]||S.style(e,r)}if((u=!S.isEmptyObject(t))||!S.isEmptyObject(d))for(r in f&&1===e.nodeType&&("overflow"in n&&(n.overflow=[h.overflow,h.overflowX,h.overflowY]),null==(l=v&&v.display))&&(l=Y.get(e,"display")),"none"===(c=S.css(e,"display"))&&("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float"))&&("inline"===c||"inline-block"===c&&null!=l)&&"none"===S.css(e,"float"))&&(u||(p.done(function(){h.display=l}),null==l&&("none"===c?c="":c=l,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1,d)u||(v?"hidden"in v&&(g=v.hidden):v=Y.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&le([e],!0),p.done(function(){for(r in g||le([e]),Y.remove(e,"fxshow"),d)S.style(e,r,d[r])})),u=ct(g?v[r]:0,r,p),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}]},prefilter:function(e,t){t?ft.prefilters.unshift(e):ft.prefilters.push(e)}}) ``` -------------------------------- ### Gevent with Greenlets Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Demonstrates creating and managing greenlets, which are the fundamental units of concurrency in gevent. This example shows how to spawn greenlets and wait for them to complete. ```python from gevent import greenlet def foo(): print 'foo' gevent.sleep(1) print 'foo done' def bar(): print 'bar' gevent.sleep(1) print 'bar done' g1 = greenlet(foo) g2 = greenlet(bar) g1.switch() g2.switch() print 'done' ``` -------------------------------- ### Gevent with Gevent-WSGI Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Provides a basic example of a web server using Gevent-WSGI. This snippet shows how to run a WSGI application with Gevent for high concurrency. ```python from gevent.pywsgi import WSGIServer def simple_app(environ, start_response): status = '200 OK' headers = [('Content-type', 'text/plain')] start_response(status, headers) return ["Hello world!"] httpd = WSGIServer(('0.0.0.0', 8000), simple_app) print('Serving on http://0.0.0.0:8000') httpd.serve_forever() ``` -------------------------------- ### Gevent Hub and Event Loop Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Shows how to interact with the Gevent hub, which manages the event loop and greenlets. This example demonstrates yielding control back to the hub. ```python from gevent import monkey monkey.patch_all() from gevent import sleep, GreenletExit def my_coroutine(): print('Coroutine started') try: sleep(2) # Yield control to the hub except GreenletExit: print('Coroutine exiting') print('Coroutine finished') from gevent import spawn g = spawn(my_coroutine) g.join() # Wait for the greenlet to complete ``` -------------------------------- ### Generic GET and POST Methods Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Provides generic methods for making GET and POST requests. These are convenient wrappers around the main AJAX function. ```JavaScript S.each(["get", "post"], function(e, i) { S[i] = function(e, t, n, r) { return m(t) && (r = r || n, n = t, t = void 0), S.ajax(S.extend({ url: e, type: i, dataType: r, data: t, success: n }, S.isPlainObject(e) && e)) } }); ``` -------------------------------- ### Basic Gevent Coroutine Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Demonstrates the creation and execution of a simple coroutine using Gevent. This is useful for understanding the fundamental building blocks of asynchronous operations. ```python from gevent import monkey monkey.patch_all() from gevent import spawn def foo(msg): print('msg: %s' % msg) spawn(foo, 'Hello') spawn(foo, 'World') # Keep the main thread alive to allow spawned coroutines to finish input('Press Enter to exit\n') ``` -------------------------------- ### Setting and Getting HTML Content Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Sets or gets the HTML content of elements. When setting, it first cleans the element and then appends the new HTML. ```javascript html:function(e){return $(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ne.test(e)&&!ge[(de.exec(e)||["",""“"])[1].toLowerCase()]){e=S.htmlPrefilter(e);try{for(;n('Convert To Integer', '1')> failed with ValueError ``` -------------------------------- ### Python Error Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html Illustrates an error occurring during the execution of `run_coroutines` in the GeventLibrary, potentially related to bundle execution. ```python Traceback (most recent call last): File "C:\workspace-vscode\robotframework-gevent\utests\test_bundle_creation.py", line 109, in test_bundle_is_empty_after_execution gevent_library_instance.run_coroutines() ``` -------------------------------- ### BundleHasNoCoroutines Exception in run_coroutines Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 18102022.html This traceback illustrates the BundleHasNoCoroutines exception being raised when `run_coroutines` is called on a bundle that contains no coroutines. This indicates a setup issue where coroutines were not added before execution. ```text ====================================================================== ERROR: test_bundle_is_empty_after_execution (utests.test_bundle_creation.TestInstanceCreation) After the bundle is executed, the coroutines should be deleted. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\workspace-vscode\robotframework-gevent\utests\test_bundle_creation.py", line 109, in test_bundle_is_empty_after_execution gevent_library_instance.run_coroutines() File "C:\workspace-vscode\robotframework-gevent\src\GeventLibrary\keywords\gevent_keywords.py", line 205, in run_coroutines raise BundleHasNoCoroutines( GeventLibrary.exceptions.BundleHasNoCoroutines: The given bundle has no coroutines, please use `Add Coroutine` keyword ``` ```text ====================================================================== ERROR: test_keyword_raise_exception (utests.test_bundle_creation.TestInstanceCreation) After the bundle is executed, the coroutines should be deleted. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\workspace-vscode\robotframework-gevent\utests\test_bundle_creation.py", line 217, in test_keyword_raise_exception gevent_library_instance.run_coroutines() File "C:\workspace-vscode\robotframework-gevent\src\GeventLibrary\keywords\gevent_keywords.py", line 205, in run_coroutines raise BundleHasNoCoroutines( GeventLibrary.exceptions.BundleHasNoCoroutines: The given bundle has no coroutines, please use `Add Coroutine` keyword ``` ```text ====================================================================== ERROR: test_order_of_returned_values (utests.test_bundle_creation.TestInstanceCreation) After the bundle is executed, the coroutines should be deleted. ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\workspace-vscode\robotframework-gevent\utests\test_bundle_creation.py", line 186, in test_order_of_returned_values values = gevent_library_instance.run_coroutines() File "C:\workspace-vscode\robotframework-gevent\src\GeventLibrary\keywords\gevent_keywords.py", line 205, in run_coroutines raise BundleHasNoCoroutines( GeventLibrary.exceptions.BundleHasNoCoroutines: The given bundle has no coroutines, please use `Add Coroutine` keyword ``` -------------------------------- ### Gevent Monkey Patching Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Illustrates the use of gevent's monkey patching to make standard library functions asynchronous. This is crucial for enabling gevent's concurrency features. ```Python from gevent import monkey monkey.patch_all() ``` -------------------------------- ### Theme Management Functions Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Provides functions to set and get the current theme for the application, supporting custom themes, dark mode preference, and a default light theme. ```javascript function setTheme(theme) { document.documentElement.setAttribute('data-theme', theme || getTheme()); } function getTheme() { if (libdoc['theme']) { return libdoc['theme']; } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { return 'dark'; } else { return 'light;' } } ``` -------------------------------- ### jQuery Event Handling Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html This snippet demonstrates advanced event handling in jQuery, including triggering custom events and managing event namespaces. It shows how to simulate events and handle focus-related events like focusin and focusout. ```javascript S.event.trigger(e,t,n,r){var i,o,a,s,u,l,c,f,p=[n||E],d=v.call(e,"type")?e.type:e,h=v.call(e,"namespace")?e.namespace.split("."):\[\];if(o=f=a=n=n||E,3!==n.nodeType&&8!==n.nodeType&&!bt.test(d+S.event.triggered)&&(-1 default pending=0 ref=0 callbacks=0 thread_ident=0xb384> Handles: [HandleState(handle=, type=b'check', watcher= default pending=0 ref=0 callbacks=0>, ref=0, active=1, closing=0), HandleState(handle=, type=b'timer', watcher= default pending=0 ref=0 callbacks=0>, ref=0, active=1, closing=0), HandleState(handle=, type=b'prepare', watcher= default pending=0 ref=0 callbacks=0>, ref=0, active=1, closing=0), HandleState(handle=, type=b'check', watcher= default pending=0 ref=0 callbacks=0>, ref=1, active=0, closing=0), HandleState(handle=, type=b'async', watcher=. at 0x000002BC29B339A0> args=() watcher= handle= ref=False>, ref=0, active=1, closing=0)] ``` -------------------------------- ### JavaScript Function for Initiating Search Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Handles the search functionality by capturing the current time, getting the search input value, and triggering a requestAnimationFrame to mark and highlight matches. If the search input is empty, it resets the keywords. ```javascript let searchTime = 0; function searching() { searchTime = Date.now(); const value = document.getElementsByClassName('search-input')[0].value; const include = {name: true, args: true, doc: true, tags: true}; if (value) { requestAnimationFrame(function () { markMatches(value, include, searchTime, function () { highlightMatches(value, include, searchTime); document.getElementById('keyword-shortcuts-container').scrollTop = 0; } ); }); } else { resetKeywords(); } } ``` -------------------------------- ### Finding Closest Ancestor with .closest() Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Use the .closest() method to get the first ancestor element that matches a specified selector or DOM element, starting from the current element and moving up the DOM tree. It returns a new jQuery object containing the closest matching ancestor. ```javascript closest: function(e, t) { var n, r = 0, i = this.length, o = [], a = "string" != typeof e && S(e); if (!k.test(e)) for (; r < i; r++) for (n = this[r]; n && n !== t; n = n.parentNode) if (n.nodeType < 11 && (a ? -1 < a.index(n) : 1 === n.nodeType && S.find.matchesSelector(n, e))) { o.push(n); break; } return this.pushStack(1 < o.length ? S.uniqueSort(o) : o); } ``` -------------------------------- ### Document Ready Initialization and Rendering Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Handles the document ready event to parse templates, set the document title, initialize storage, set the theme, and render various sections of the documentation using jQuery and custom templates. ```javascript $(document).ready(function() { parseTemplates(); document.title = libdoc.name; storage.init('libdoc'); setTheme(); renderTemplate('base', libdoc, $('body')); if (libdoc.inits.length) { libdoc.typedocs.map(function(type) { var index = type.usages.indexOf('\_ egotiable b__init b__'); if (index != -1) type.usages[index] = 'Importing'; }); renderTemplate('importing', libdoc); } renderTemplate('shortcuts', libdoc); renderTemplate('keyword-shortcuts', libdoc); renderTemplate('keywords', libdoc); renderTemplate('data-types', libdoc); renderTemplate('footer', libdoc); const params = util.parseQueryString(window.location.search.slice(1)); let selectedTag = ""; if ("tag" in params) { selectedTag = params["tag"]; tagSearch(selectedTag, window.location.hash); } if (libdoc.tags.length) { libdoc.selectedTag = selectedTag; renderTemplate('tags-shortcuts', libdoc); } scrollToHash(); setTimeout(function() { document.getElementById("keyword-statistics-header").innerText = '' + libdoc.keywords.length; if (storage.get('keyword-wall') === 'open') { openKeywordWall(); } }, 0); createModal(); }); ``` -------------------------------- ### Get JSON Data Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Shorthand method for making GET requests and expecting JSON. Use this when you need to retrieve JSON data from a server. ```JavaScript getJSON: function(e, t, n) { return S.get(e, t, n, "json") } ``` -------------------------------- ### Deferred Object Creation and Basic Usage Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Illustrates how to create a Deferred object and use its methods for handling asynchronous operations. This is fundamental for managing callbacks and errbacks. ```javascript var deferred = S.Deferred(); deferred.done(function(result) { console.log("Success: " + result); }).fail(function(error) { console.log("Error: " + error); }); // To resolve the deferred: deferred.resolve("Operation completed successfully"); // To reject the deferred: // deferred.reject("An error occurred"); ``` -------------------------------- ### Get Offset Parent Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Finds the closest positioned ancestor element. ```javascript S.fn.offsetParent = function() { return this.map(function() { var e = this.offsetParent; while (e && "static" === S.css(e, "position")) e = e.offsetParent; return e || re }) }; ``` -------------------------------- ### Robot Framework Test Case with GeventLibrary Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/README.md A Robot Framework test case demonstrating the usage of GeventLibrary for asynchronous keyword execution. It shows how to create a gevent bundle, add coroutines, and run them asynchronously. ```robotframework # simple-test.robot *** Settings *** Library Collections Library String Library GeventLibrary Library RequestsLibrary *** Test Cases *** Test1 [Documentation] Simple test flow with gevent greenlets Log Hello World Create Gevent Bundle alias=alias1 # Create a bundle of coroutines Sleep 10s alias=alias1 # run your synchronous keyword # register all your keywords as coroutines to the gevent bundle Add Coroutine Sleep Wrapper alias=alias1 Add Coroutine Sleep 20s alias=alias1 Add Coroutine Sleep 10s alias=alias1 Add Coroutine GET https://jsonplaceholder.typicode.com/posts/1 alias=alias1 Add Coroutine Convert To Lower Case UPPER # Run your coroutines and get the values by order ${values} Run Coroutines alias=alias1 Log Many @{values} # The 3rd coroutine was a request, take it's value ${jsonplaceholder_resp} Get From List ${values} 3 # assert the returned response code to be 200 Status Should Be 200 ${jsonplaceholder_resp} # assert that the returned `userId` field equals to 1 Should Be Equal As Strings 1 ${jsonplaceholder_resp.json()['userId']} *** Keywords *** Sleep Wrapper Sleep 1s ``` -------------------------------- ### Get Element Offset Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Retrieves the position of an element relative to the document. ```javascript S.fn.offset = function(t) { if (arguments.length) return void 0 === t ? this : this.each(function(e) { S.offset.setOffset(this, t, e) }); var e, n, r = this[0]; return r ? r.getClientRects().length ? (e = r.getBoundingClientRect(), n = r.ownerDocument.defaultView, { top: e.top + n.pageYOffset, left: e.left + n.pageXOffset }) : { top: 0, left: 0 } : void 0 }; ``` -------------------------------- ### Scroll Element Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Gets or sets the horizontal or vertical scroll position of elements. ```javascript S.each(S.scrollLeft = "pageXOffset", S.scrollTop = "pageYOffset", function(t, i) { var o = "pageYOffset" === i; S.fn[t] = function(e) { return $(this, function(e, t, n) { var r; if (x(e) ? r = e : 9 === e.nodeType && (r = e.defaultView), void 0 === n) return r ? r[i] : e[t]; r ? r.scrollTo(o ? r.pageXOffset : n, o ? n : r.pageYOffset) : e[t] = n }, t, e, arguments.length) } }); ``` -------------------------------- ### Chaining Deferred Operations with 'then' Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Demonstrates how to chain multiple asynchronous operations using the 'then' method. This allows for sequential execution of callbacks based on the resolution of previous operations. ```javascript var deferred = S.Deferred(); deferred.then( function resolveHandler(result) { console.log("First step result: " + result); return "Second step result"; // This will be passed to the next 'then' }, function rejectHandler(error) { console.error("An error occurred: " + error); }, function notifyHandler(progress) { console.log("Progress: " + progress); } ).then( function resolveHandler2(result2) { console.log("Second step result: " + result2); }, function rejectHandler2(error2) { console.error("Error in second step: " + error2); } ); deferred.resolve("Initial data"); ``` -------------------------------- ### Get Element Position Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Calculates the position of an element relative to its offset parent. ```javascript S.fn.position = function() { if (this[0]) { var e, t, n, r = this[0], i = { top: 0, left: 0 }; if ("fixed" === S.css(r, "position")) t = r.getBoundingClientRect(); else { t = this.offset(), n = r.ownerDocument, e = r.offsetParent || n.documentElement; while (e && (e === n.body || e === n.documentElement) && "static" === S.css(e, "position")) e = e.parentNode; e && e !== r && 1 === e.nodeType && (i = S(e).offset()).top += S.css(e, "borderTopWidth", !0), i.left += S.css(e, "borderLeftWidth", !0) } return { top: t.top - i.top - S.css(r, "marginTop", !0), left: t.left - i.left - S.css(r, "marginLeft", !0) } } }; ``` -------------------------------- ### Handling Multiple Deferreds with 'when' Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Shows how to use the 'when' method to manage multiple Deferred objects. It resolves when all provided Deferreds have resolved, or rejects as soon as one rejects. ```javascript var deferred1 = S.Deferred(); var deferred2 = S.Deferred(); S.when(deferred1, deferred2).done(function(result1, result2) { console.log("All operations completed."); console.log("Result 1: " + result1); console.log("Result 2: " + result2); }).fail(function(error) { console.error("One of the operations failed: " + error); }); // Simulate operations deferred1.resolve("Data from operation 1"); deferred2.resolve("Data from operation 2"); // Example of failure: // deferred1.reject("Error in operation 1"); ``` -------------------------------- ### Python AssertionError Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html Shows an AssertionError in a test case where an expected exception (AliasAlreadyCreated) was not raised. ```python with self.assertRaises(AliasAlreadyCreated) as exp: pass AssertionError: AliasAlreadyCreated not raised ``` -------------------------------- ### Run Robot Framework Test Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/README.md Command to execute the Robot Framework test case. Ensure the test file is in the current directory. ```bash robot simple-test.robot ``` -------------------------------- ### Gevent Library Initialization and Core Functions Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html This snippet shows the initialization of the Gevent library and its core functions like 'compile' and 'select'. It's used for setting up the library's internal structures and preparing for query execution. ```javascript var h=se.tokenize=function(e,t){var n,r,i,o,a,s,u,l=x[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=b.preFilter;while(a){for(o in n&&!(r=z.exec(a))||(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=z.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace($," ")}),a=a.slice(n.length)),b.filter)!(r=G[o].exec(a))||u[o]&&!(r=u[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?se.error(e):x(e,s).slice(0)},f=se.compile=function(e,t){var n,v,y,m,x,r,i=[],o=[],a=A[e+" "];if(!a){t||(t=h(e)),n=t.length;while(n--)(a=Ee(t[n]))[S]?i.push(a):o.push(a);(a=A(e,(v=o,m=0<(y=i).length,x=0, type=b'prepare', watcher= default pending=0 ref=0 callbacks=0>, ref=0, active=1, closing=0), HandleState(handle=, type=b'check', watcher= default pending=0 ref=0 callbacks=0>, ref=1, active=0, closing=0), HandleState(handle=, type=b'async', watcher=. at 0x0000022D0BDF39A0> args=() watcher= handle= ref=False>, ref=0, active=1, closing=0) ``` -------------------------------- ### Test Run Summary Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html This summary indicates that out of 13 tests run, 11 resulted in errors. The primary error type observed is 'NoBundleCreated'. ```text ---------------------------------------------------------------------- Ran 13 tests in 0.011s FAILED (errors=11) ``` -------------------------------- ### Running Coroutines with Gevent Pool Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html This snippet shows how to run coroutines using a Gevent pool. It demonstrates calling the `run_coroutines` keyword with a specified pool size. Note that a pool size of 0 can lead to a `LoopExit` exception. ```Python gevent_library_instance.run_coroutines(gevent_pool_size=0) ``` -------------------------------- ### AssertionError: ValueError not raised Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html This failure indicates that a ValueError was expected but not raised when testing the 'gevent_pool_size' with a negative number. The test setup likely involved mocking to assert the exception. ```python with mock.patch( ( "src.GeventLibrary.keywords.gevent_keywords.GeventLibrary.run_coroutines" ) ) as mock_run_coroutines: mock_run_coroutines.side_effect = ValueError( "'gevent_pool_size' must be a non negative value, got -1" ) with pytest.raises(ValueError): gevent_library_instance.run_coroutines(gevent_pool_size=-1) ``` -------------------------------- ### Robot Framework Gevent Add Coroutine Example Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html This snippet shows how to add a coroutine to the Gevent library instance in Robot Framework. It was part of a test case that resulted in an IndexError. ```robotframework gevent_library_instance.add_coroutine("Convert To Integer", "1") ``` -------------------------------- ### Gevent Hub and Events Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/GeventLibrary.html Illustrates the use of the gevent hub for managing events and callbacks. This snippet shows how to create a custom event and signal it. ```python from gevent.hub import Hub def callback(event_data): print 'Callback received:', event_data hub = Hub() event = hub.event() hub.subscribe(event, callback) hub.schedule(event, 'some data') hub.wait(event) ``` -------------------------------- ### Gevent Job List Handling Source: https://github.com/eldaduzman/robotframework-gevent/blob/main/docs/mutation-testing/MutationTesting - 19092022.html Illustrates the state of handles within the gevent loop, showing active and inactive jobs. Useful for debugging and understanding gevent's internal job management. ```python HandleState(handle=, type=b'check', watcher= default pending=0 ref=0 callbacks=0>, ref=1, active=0, closing=0), HandleState(handle=, type=b'async', watcher=. at 0x0000017EA1783370> args=() watcher= handle= ref=False>, ref=0, active=1, closing=0) ```