How to use with_ method in Selene

Best Python code snippet using selene_python

test_build.py

Source:test_build.py Github

copy

Full Screen

...182 lambda: select("x").from_("tbl").offset(10),183 "SELECT x FROM tbl OFFSET 10",184 ),185 (186 lambda: select("x").from_("tbl").with_("tbl", as_="SELECT x FROM tbl2"),187 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl",188 ),189 (190 lambda: select("x")191 .from_("tbl")192 .with_("tbl", as_="SELECT x FROM tbl2", recursive=True),193 "WITH RECURSIVE tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl",194 ),195 (196 lambda: select("x")197 .from_("tbl")198 .with_("tbl", as_=select("x").from_("tbl2")),199 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl",200 ),201 (202 lambda: select("x")203 .from_("tbl")204 .with_("tbl (x, y)", as_=select("x", "y").from_("tbl2")),205 "WITH tbl(x, y) AS (SELECT x, y FROM tbl2) SELECT x FROM tbl",206 ),207 (208 lambda: select("x")209 .from_("tbl")210 .with_("tbl", as_=select("x").from_("tbl2"))211 .with_("tbl2", as_=select("x").from_("tbl3")),212 "WITH tbl AS (SELECT x FROM tbl2), tbl2 AS (SELECT x FROM tbl3) SELECT x FROM tbl",213 ),214 (215 lambda: select("x")216 .from_("tbl")217 .with_("tbl", as_=select("x", "y").from_("tbl2"))218 .select("y"),219 "WITH tbl AS (SELECT x, y FROM tbl2) SELECT x, y FROM tbl",220 ),221 (222 lambda: select("x")223 .with_("tbl", as_=select("x").from_("tbl2"))224 .from_("tbl"),225 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl",226 ),227 (228 lambda: select("x")229 .with_("tbl", as_=select("x").from_("tbl2"))230 .from_("tbl")231 .group_by("x"),232 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl GROUP BY x",233 ),234 (235 lambda: select("x")236 .with_("tbl", as_=select("x").from_("tbl2"))237 .from_("tbl")238 .order_by("x"),239 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl ORDER BY x",240 ),241 (242 lambda: select("x")243 .with_("tbl", as_=select("x").from_("tbl2"))244 .from_("tbl")245 .limit(10),246 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl LIMIT 10",247 ),248 (249 lambda: select("x")250 .with_("tbl", as_=select("x").from_("tbl2"))251 .from_("tbl")252 .offset(10),253 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl OFFSET 10",254 ),255 (256 lambda: select("x")257 .with_("tbl", as_=select("x").from_("tbl2"))258 .from_("tbl")259 .join("tbl3"),260 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl JOIN tbl3",261 ),262 (263 lambda: select("x")264 .with_("tbl", as_=select("x").from_("tbl2"))265 .from_("tbl")266 .distinct(),267 "WITH tbl AS (SELECT x FROM tbl2) SELECT DISTINCT x FROM tbl",268 ),269 (270 lambda: select("x")271 .with_("tbl", as_=select("x").from_("tbl2"))272 .from_("tbl")273 .where("x > 10"),274 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl WHERE x > 10",275 ),276 (277 lambda: select("x")278 .with_("tbl", as_=select("x").from_("tbl2"))279 .from_("tbl")280 .having("x > 20"),281 "WITH tbl AS (SELECT x FROM tbl2) SELECT x FROM tbl HAVING x > 20",282 ),283 (lambda: select("x").from_("tbl").subquery(), "(SELECT x FROM tbl)"),284 (285 lambda: select("x").from_("tbl").subquery("y"),286 "(SELECT x FROM tbl) AS y",287 ),288 (289 lambda: select("x").from_(select("x").from_("tbl").subquery()),290 "SELECT x FROM (SELECT x FROM tbl)",291 ),292 (lambda: from_("tbl").select("x"), "SELECT x FROM tbl"),...

Full Screen

Full Screen

test_make_it_easy.py

Source:test_make_it_easy.py Github

copy

Full Screen

...6 my_apple = make(an(apple))7 assert_that(my_apple.num_of_leaves, is_(equal_to(2)))8 assert_that(my_apple.is_ripe, is_(False))9 def test_overrides_default_values_with_explicit_properties(self):10 my_apple = make(an(apple, with_(3, 'leaves'), with_(0.95, 'ripeness')))11 assert_that(my_apple.num_of_leaves, is_(equal_to(3)))12 assert_that(my_apple.is_ripe, is_(True))13 def test_can_use_maker_to_initialize_property_value(self):14 a_customer = a(customer, with_('Alice', as_('name')))15 an_order = make(an(order, with_(a_customer, as_('customer_'))))16 assert_that(an_order.customer.name, is_(equal_to('Alice')))17 def test_can_use_maker_with_option_to_initialize_property_value(self):18 a_customer = a(customer).with_('Alice', as_('name'))19 an_order = make(an(order, with_(a_customer, as_('customer_'))))20 assert_that(an_order.customer.name, is_(equal_to('Alice')))21 def test_a_distinct_property_value_instance_is_used_for_made_object_when_property_is_defined_with_a_maker(self):22 an_order = an(order, with_(a(customer, with_('Bob', as_('name'))), as_('customer_')))23 my_order1 = make(an_order)24 my_order2 = make(an_order)25 assert_that(my_order1.customer, is_not(same_instance(my_order2.customer)))26 def test_can_explicitly_declare_that_different_instances_have_the_same_property_value_instance(self):27 a_customer = a(customer, with_('Bob', as_('name')))28 an_order = an(order, with_(the_same(a_customer), as_('customer_')))29 my_order1 = make(an_order)30 my_order2 = make(an_order)31 assert_that(my_order1.customer, is_(same_instance(my_order2.customer)))32 def test_distinct_collection_elements_are_used_for_each_made_object_when_elements_are_defined_with_a_maker(self):33 a_fruits_bowl = a(fruits_bowl, with_(list_of(an(apple), a(banana)), 'fruits'))34 fruits_bowl1 = make(a_fruits_bowl)35 fruits_bowl2 = make(a_fruits_bowl)36 assert_that(fruits_bowl1.fruits, is_not(same_instance(fruits_bowl2.fruits)))37 assert_that(fruits_bowl1.fruits[0], is_not(same_instance(fruits_bowl2.fruits[0])))38 assert_that(fruits_bowl1.fruits[1], is_not(same_instance(fruits_bowl2.fruits[1])))39 def test_can_declare_that_elements_of_different_collection_are_the_same(self):40 a_fruits_bowl = a(fruits_bowl, with_(list_of(the_same(apple), the_same(banana)), 'fruits'))41 fruits_bowl1 = make(a_fruits_bowl)42 fruits_bowl2 = make(a_fruits_bowl)43 assert_that(fruits_bowl1.fruits, is_not(same_instance(fruits_bowl2.fruits)))44 assert_that(fruits_bowl1.fruits[0], same_instance(fruits_bowl2.fruits[0]))45 assert_that(fruits_bowl1.fruits[1], same_instance(fruits_bowl2.fruits[1]))46 def test_can_declare_that_same_collection_is_used_for_every_made_object(self):47 a_fruits_bowl = a(fruits_bowl, with_(the_same(list_of(an(apple), a(banana))), 'fruits'))48 fruits_bowl1 = make(a_fruits_bowl)49 fruits_bowl2 = make(a_fruits_bowl)50 assert_that(fruits_bowl1.fruits, is_(same_instance(fruits_bowl2.fruits)))51 def test_can_use_a_maker_as_a_donor(self):52 a_customer = a(customer, with_('Bob', as_('name')))53 an_order = an(order, with_(a_customer, as_('customer_')))54 my_order = make(an_order)55 assert_that(my_order.customer, is_(instance_of(Customer)))56 def test_can_declare_a_maker_as_a_base_maker_using_but(self):57 apple_with_two_leaves = an(apple, with_(2, 'leaves'))58 ripe_apple = apple_with_two_leaves.but(with_(0.95, 'ripeness'))59 unripe_apple = apple_with_two_leaves.but(with_(0.1, 'ripeness'))60 apple1 = make(ripe_apple)61 apple2 = make(unripe_apple)62 assert_that(apple1.is_ripe, is_(True))63 assert_that(apple2.is_ripe, is_(False))64def fruits_bowl(fruits=None):65 return FruitsBowl(fruits or [])66class FruitsBowl(object):67 def __init__(self, fruits):68 self.fruits = fruits69def apple(leaves=2, ripeness=0.0):70 an_apple = Apple(leaves)71 an_apple.ripen(ripeness)72 return an_apple73class Fruit(object):...

Full Screen

Full Screen

gears.py

Source:gears.py Github

copy

Full Screen

1from math import pi2class Arm:3 def __init__(self, length):4 self.length = length5class Gear:6 def __init__(self, diameter: float, teeth: int, direction: str = 'external'):7 self.diameter = diameter8 self.teeth = teeth9 self.direction = direction10 self.module = (self.diameter/self.teeth)11 @classmethod12 def by_module(cls, module: float, diameter: float, direction: str = 'external'):13 teeth = (diameter/module)14 if not float(teeth).is_integer():15 raise ValueError("Invalid input")16 return cls(diameter, int(teeth), direction)17 def __str__(self):18 return f"{self.direction} Gear, M-{self.module}"19class GearTrain:20 def __init__(self, gear):21 self.gears = [gear]22 gear.fixed_shaft = True23 gear.mesh_attachment = []24 gear.shaft_attachment = []25 self.driver = None26 self.follower = None27 self.velocity_ratio = None28 @staticmethod29 def _equal_module(gear_1, gear_2):30 if gear_1.module == gear_2.module:31 return True32 return False33 def add_gear_in_mesh(self, new_gear, with_, fixed_shaft=True, is_fixed=False):34 if with_ not in self.gears: # Checks if the gear is already exists in geartrain. 35 raise ValueError("The gear is not in gearset")36 else:37 if self._equal_module(new_gear, with_): # Check for module equality38 self.gears.append(new_gear)39 new_gear.mesh_attachment = [with_]40 with_.mesh_attachment.append(new_gear)41 new_gear.fixed_shaft = fixed_shaft42 new_gear.is_fixed = is_fixed43 else:44 raise ValueError(f"modules of two gears are different")45 def add_gear_with_shaft(self, new_gear, with_):46 if with_ not in self.gears:47 raise ValueError("The gear is not in gearset")48 else:49 self.gears.append(new_gear)50 with_.shaft_attachment.append(new_gear)51 new_gear.shaft_attachment = [with_]52 def add_driver(self, gear, velocity):53 self.driver = gear54 self.gears.append(gear)55 self.driver.velocity = velocity56 def set_follower(self, gear):57 self.follower = gear58 @property59 def output_velocity(self):60 if self.follower == None:61 raise ValueError("follower isn't defined yet")...

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