How to use derived_value method in hypothesis

Best Python code snippet using hypothesis

test_derived.py

Source:test_derived.py Github

copy

Full Screen

1"""2Tests for derived.py3"""4import sys5from unittest import TestCase6from openedx.core.lib.derived import derived, derived_collection_entry, derive_settings, clear_for_tests7class TestDerivedSettings(TestCase):8 """9 Test settings that are derived from other settings.10 """11 def setUp(self):12 super(TestDerivedSettings, self).setUp()13 clear_for_tests()14 self.module = sys.modules[__name__]15 self.module.SIMPLE_VALUE = 'paneer'16 self.module.DERIVED_VALUE = lambda settings: 'mutter ' + settings.SIMPLE_VALUE17 self.module.ANOTHER_DERIVED_VALUE = lambda settings: settings.DERIVED_VALUE + ' with naan'18 self.module.UNREGISTERED_DERIVED_VALUE = lambda settings: settings.SIMPLE_VALUE + ' is cheese'19 derived('DERIVED_VALUE', 'ANOTHER_DERIVED_VALUE')20 self.module.DICT_VALUE = {}21 self.module.DICT_VALUE['test_key'] = lambda settings: settings.DERIVED_VALUE * 322 derived_collection_entry('DICT_VALUE', 'test_key')23 self.module.DICT_VALUE['list_key'] = ['not derived', lambda settings: settings.DERIVED_VALUE]24 derived_collection_entry('DICT_VALUE', 'list_key', 1)25 def test_derived_settings_are_derived(self):26 derive_settings(__name__)27 self.assertEqual(self.module.DERIVED_VALUE, 'mutter paneer')28 self.assertEqual(self.module.ANOTHER_DERIVED_VALUE, 'mutter paneer with naan')29 def test_unregistered_derived_settings(self):30 derive_settings(__name__)31 self.assertTrue(callable(self.module.UNREGISTERED_DERIVED_VALUE))32 def test_derived_settings_overridden(self):33 self.module.DERIVED_VALUE = 'aloo gobi'34 derive_settings(__name__)35 self.assertEqual(self.module.DERIVED_VALUE, 'aloo gobi')36 self.assertEqual(self.module.ANOTHER_DERIVED_VALUE, 'aloo gobi with naan')37 def test_derived_dict_settings(self):38 derive_settings(__name__)39 self.assertEqual(self.module.DICT_VALUE['test_key'], 'mutter paneermutter paneermutter paneer')40 def test_derived_nested_settings(self):41 derive_settings(__name__)...

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