How to use caching method in Selene

Best Python code snippet using selene_python

test_auth.py

Source:test_auth.py Github

copy

Full Screen

1"""Test for auth methods supported by MySQL 8"""2import os3import pymysql4# pymysql.connections.DEBUG = True5# pymysql._auth.DEBUG = True6host = "127.0.0.1"7port = 33068ca = os.path.expanduser("~/ca.pem")9ssl = {'ca': ca, 'check_hostname': False}10def test_sha256_no_password():11 con = pymysql.connect(user="nopass_sha256", host=host, port=port, ssl=None)12 con.close()13def test_sha256_no_passowrd_ssl():14 con = pymysql.connect(user="nopass_sha256", host=host, port=port, ssl=ssl)15 con.close()16def test_sha256_password():17 con = pymysql.connect(user="user_sha256", password="pass_sha256", host=host, port=port, ssl=None)18 con.close()19def test_sha256_password_ssl():20 con = pymysql.connect(user="user_sha256", password="pass_sha256", host=host, port=port, ssl=ssl)21 con.close()22def test_caching_sha2_no_password():23 con = pymysql.connect(user="nopass_caching_sha2", host=host, port=port, ssl=None)24 con.close()25def test_caching_sha2_no_password():26 con = pymysql.connect(user="nopass_caching_sha2", host=host, port=port, ssl=ssl)27 con.close()28def test_caching_sha2_password():29 con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)30 con.close()31 # Fast path of caching sha232 con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)33 con.query("FLUSH PRIVILEGES")34 con.close()35def test_caching_sha2_password_ssl():36 con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=ssl)37 con.close()38 # Fast path of caching sha239 con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)40 con.query("FLUSH PRIVILEGES")...

Full Screen

Full Screen

test_caching.py

Source:test_caching.py Github

copy

Full Screen

...50def test_factorial_value():51 for n in range(10):52 ans = _factorial(n)53 assert ans == math.factorial(n)54def _test_factorial_caching(n):55 counter = [0]56 _factorial(n, counter)57 assert counter[0] == n58def test_factorial_caching_1():59 _test_factorial_caching(1)60def test_factorial_caching_10():61 _test_factorial_caching(10)62def test_factorial_caching_30():63 _test_factorial_caching(30)64if __name__ == '__main__':65 import pytest...

Full Screen

Full Screen

100-lfu_cache.py

Source:100-lfu_cache.py Github

copy

Full Screen

1#!/usr/bin/python32"""Create a Caching System."""3import base_caching4class LFUCache(base_caching.BaseCaching):5 """A class LFUCache that inherits from BaseCaching."""6 def __init__(self):7 """Overload init."""8 super().__init__()9 self.CachingKeys = []10 def put(self, key, item):11 """Must assign to the dictionary."""12 if key is None or item is None:13 return14 AmountOfKeys = len(self.CachingKeys)15 if AmountOfKeys == base_caching.BaseCaching.MAX_ITEMS:16 print("DISCARD: {}".format(str(self.CachingKeys[-1])))17 del self.cache_data[self.CachingKeys[-1]]18 self.CachingKeys = self.CachingKeys[:-1]19 if key in self.CachingKeys:20 self.CachingKeys.remove(key)21 self.CachingKeys.append(key)22 self.cache_data[key] = item23 def get(self, key):24 """Must return the value."""25 if key is not None and key in self.CachingKeys:26 self.CachingKeys.remove(key)27 self.CachingKeys.append(key)28 return self.cache_data.get(key)...

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