How to use test_usage method in hypothesis

Best Python code snippet using hypothesis

test_typeutils.py

Source:test_typeutils.py Github

copy

Full Screen

2# encoding: utf-83from unittest import TestCase4from ycyc.base import typeutils5class TestSubType(TestCase):6 def test_usage(self):7 self.assertTrue(issubclass(8 typeutils.subtype("Test"),9 object10 ))11 self.assertTrue(issubclass(12 typeutils.subtype("Test", dict),13 dict14 ))15 self.assertTrue(issubclass(16 typeutils.subtype("Test", (dict,)),17 dict18 ))19 TestType = typeutils.subtype("Test", object, {"val": 1})20 self.assertEqual(TestType.__name__, "Test")21 self.assertEqual(TestType.val, 1)22 obj = TestType()23 self.assertEqual(obj.val, 1)24class TestTypesFactory(TestCase):25 def test_usage(self):26 TestType = typeutils.types_factory.TestType()27 self.assertTrue(issubclass(TestType, object))28 self.assertIsNot(TestType, typeutils.types_factory.TestType())29 self.assertTrue(issubclass(30 typeutils.types_factory.TestType(dict),31 dict32 ))33 TestType = typeutils.types_factory.TestType(attrs={"val": 1})34 self.assertEqual(TestType.__name__, "TestType")35 self.assertEqual(TestType.val, 1)36 obj = TestType()37 self.assertEqual(obj.val, 1)38class TestSubException(TestCase):39 def test_usage(self):40 self.assertTrue(issubclass(41 typeutils.subexception("Test"),42 Exception43 ))44class TestExceptionsFactory(TestCase):45 def test_usage(self):46 TestType = typeutils.exceptions_factory.TestType()47 self.assertTrue(issubclass(TestType, Exception))48 self.assertIsNot(TestType, typeutils.exceptions_factory.TestType())49class TestSimpleExceptions(TestCase):50 def test_usage(self):51 simple_exceptions = typeutils.SimpleExceptions()52 self.assertIsInstance(simple_exceptions.NewError, type)53 self.assertIs(simple_exceptions.NewError, simple_exceptions.NewError)54class TestFreezedAttrs(TestCase):55 def test_usage(self):56 @typeutils.freezed_attrs(["name", "value"])57 class TestObj(object):58 def __init__(self, name, value):59 self.name = name60 self.value = value61 m = TestObj("test", 123)62 with self.assertRaisesRegexp(AttributeError, "name is not writable"):63 m.name = 164 self.assertEqual(m.name, "test")65 with self.assertRaisesRegexp(AttributeError, "value is not writable"):66 m.value = 167 self.assertEqual(m.value, 123)68 with self.assertRaisesRegexp(AttributeError, "noting is not writable"):69 m.noting = 170 self.assertFalse(hasattr(m, "noting"))71class TestConstants(TestCase):72 def test_usage(self):73 const = typeutils.constants(74 Id="TestConstants",75 Name="TestConstants",76 Function="test_usage",77 )78 self.assertIsInstance(const, typeutils.Constants)79 self.assertEqual(const.Id, "TestConstants") # pylint: disable=E110180 self.assertEqual(const.Name, "TestConstants") # pylint: disable=E110181 self.assertSetEqual(set(const["TestConstants"]), set(["Id", "Name"]))82 self.assertEqual(const.Function, "test_usage") # pylint: disable=E110183 self.assertTupleEqual(const["test_usage"], ("Function",)) # pylint: unsubscriptable-object84 self.assertIsNone(const["noting"])85 with self.assertRaisesRegexp(86 AttributeError,87 "attribute Name is not writable",88 ):89 const.Name = "error"90 with self.assertRaisesRegexp(91 AttributeError,92 "attribute Function is not writable",93 ):94 const.Function = "error"95 self.assertDictEqual(dict(const), {96 "Id": "TestConstants",97 "Name": "TestConstants",98 "Function": "test_usage",99 })100class TestEnums(TestCase):101 def test_usage(self):102 enums = typeutils.enums("a", "b", "c")103 self.assertEqual(enums.a, 0) # pylint: disable=E1101104 self.assertEqual(enums.b, 1) # pylint: disable=E1101105 self.assertEqual(enums.c, 2) # pylint: disable=E1101106 self.assertEqual(enums[0], "a")107 self.assertEqual(enums[1], "b")108 self.assertEqual(enums[2], "c")109 with self.assertRaisesRegexp(110 AttributeError,111 "attribute a is not writable",112 ):113 enums.a = 2114 self.assertDictEqual(dict(enums), {115 "a": 0, "b": 1, "c": 2,...

Full Screen

Full Screen

test_maintenance_usage.py

Source:test_maintenance_usage.py Github

copy

Full Screen

1from odoo.tests import common2class TestMaintenanceUsage(common.TransactionCase):3 """Tests for usage on creation and update4 """5 def test_create(self):6 test_usage = 21.07 equipment = self.env['maintenance.equipment'].create({8 'name': 'Monitor',9 'usage_qty': test_usage,10 })11 self.assertTrue(equipment.usage_log_ids)12 self.assertEqual(equipment.usage_log_ids[0].qty, test_usage)13 def test_update(self):14 test_usage = 21.015 test_usage2 = 50.116 equipment = self.env['maintenance.equipment'].create({17 'name': 'Monitor',18 'usage_qty': test_usage,19 })20 equipment.usage_qty = test_usage221 updated_usage = equipment.usage_log_ids.filtered(lambda u: abs(u.qty - test_usage2) < 0.01)22 self.assertTrue(updated_usage)23 self.assertAlmostEqual(updated_usage[0].qty, test_usage2)24 def test_maintenance_usage(self):25 test_usage = 21.026 test_usage2 = 50.127 equipment = self.env['maintenance.equipment'].create({28 'name': 'Monitor',29 'usage_qty': test_usage,30 'maintenance_usage': 20.0,31 'maintenance_team_id': self.env['maintenance.team'].search([], limit=1).id32 })33 self.assertFalse(equipment.maintenance_ids)34 equipment.usage_qty = test_usage2...

Full Screen

Full Screen

usage.py

Source:usage.py Github

copy

Full Screen

1#!/usr/local/bin/python22# @Author: Brandon Tarney3# @Date: 10/20174# Usage class is for encapsulating the usage of a program and displaying it appropriately5import sys6class Usage:7 def __init__(self, input_str):8 self.usage = list()9 self.usage.append(input_str)10 def add(self, input_str):11 self.usage.append(input_str)12 def show(self):13 for line in self.usage:14 print(line)15def main():16 test_usage = Usage("Test")17 test_usage.show()18 test_usage.add("Also test like this")19 test_usage.show()20 test_usage = Usage("Usage: python2 %s " % (sys.argv[0]))21 test_usage.show()22if __name__ == "__main__":...

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