Best Python code snippet using molotov_python
test_countminsketch.py
Source:test_countminsketch.py
...11 with self.assertRaises(ValueError):12 CountMinSketch(0, 5)13 with self.assertRaises(ValueError):14 CountMinSketch(100, 0)15 def test_simple_usage(self):16 N = 100017 sketch = CountMinSketch(10, 5)18 for _ in xrange(N):19 sketch.add("a")20 self.assertEqual(sketch.query("a"), N)21 self.assertEqual(sketch.query("b"), 0)22 self.assertEqual(len(sketch), N)23 def test_syntax_sugar(self):24 sketch = CountMinSketch(10, 5)25 self.assertEqual(sketch.query("a"), sketch["a"])26 sketch.add("a")27 self.assertEqual(sketch.query("a"), sketch["a"])28 def test_counts_overestimate(self):29 text = open(__file__).read()...
test_general.py
Source:test_general.py
1import delegator2def test_simple_usage(monkeypatch):3 """Check that cli shows prefixed variables."""4 monkeypatch.setenv('SOM_TT_VALUE', '1')5 variables = delegator.run('dump-env -p SOM_TT_')6 assert variables.out == 'VALUE=1\n'7def test_both_options(monkeypatch, env_file):8 """9 Check with template and prefix.10 CLI must show all prefixed variables by template.11 """12 monkeypatch.setenv('SOM_TT_VALUE', '1')13 variables = delegator.run('dump-env -p SOM_TT_ -t {0}'.format(env_file))14 assert variables.out == 'NORMAL_KEY=SOMEVALUE\nVALUE=1\n'15def test_multiple_prefixes(monkeypatch):16 """...
test_middleware.py
Source:test_middleware.py
1from fastapi import FastAPI, Response2from fastapi.testclient import TestClient3from fastapi_simple_cachecontrol import middleware4from fastapi_simple_cachecontrol.types import CacheControl5def test_simple_usage():6 app = FastAPI()7 app.add_middleware(8 middleware.CacheControlMiddleware, cache_control=CacheControl("public")9 )10 app.get("/")(lambda: "OK")11 response = TestClient(app).get("/")12 assert "Cache-Control" in response.headers13 assert response.headers.get("Cache-Control") == "public"14def test_ignore_already_header():15 app = FastAPI()16 app.add_middleware(17 middleware.CacheControlMiddleware, cache_control=CacheControl("public")18 )19 @app.get("/")...
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!!