Best Python code snippet using hypothesis
key_certificate.py
Source:key_certificate.py
...112 content = get_key_certificate({"fingerprint": test_value}, content = True)113 self.assertRaises(ValueError, KeyCertificate, content)114 certificate = KeyCertificate(content, False)115 self.assertEqual(test_value.strip(), certificate.fingerprint)116 def test_time_fields(self):117 """118 Parses the dir-key-published and dir-key-expires fields, which both have119 datetime content.120 """121 test_values = (122 "",123 " ",124 "2012-12-12",125 "2012-12-12 01:01:",126 "2012-12-12 01:a1:01",127 )128 for field, attr in (("dir-key-published", "published"), ("dir-key-expires", "expires")):129 for test_value in test_values:130 content = get_key_certificate({field: test_value}, content = True)...
tests.py
Source:tests.py
...106 self.assertEqual(obj.field_binary, b'hello')107 obj.field_binary = 'hello'108 self.assertEqual(obj.field_binary, 'hello', 'mismatched value type assignment is valid in Python')109 self.assertRaises(TypeError, obj.save, 'type validation and db-constraint always occurrs during saving')110 def test_time_fields(self):111 obj = TimeFields()112 self.assertIsNone(obj.field_date)113 self.assertIsNone(obj.field_datetime)114 self.assertIsNone(obj.field_time)115 obj.save()116 self.assertEqual(obj.field_date, datetime.date.today())117 self.assertEqual(obj.field_datetime.date(), datetime.date.today())118 def test_foreignkey_fields(self):119 obj_string = StringFields.objects.create(field_char='12345')120 obj_foreign_key = ForeignKeyFields.objects.create(field_foreign=obj_string)...
test_dynamics_warts.py
Source:test_dynamics_warts.py
...33 address2_resp_404 = cdms_client.get(34 'CustomerAddressSet', "guid'{0}'".format(account['Address2_AddressId'])35 )36 assert address2_resp_404.status_code == 40437def test_time_fields(account_object):38 '''39 Demonstrate that time-related fields are populated automatically by40 Dynamics.41 '''42 fields = ['CreatedOn', 'ModifiedOn']43 for field in fields:44 # this will raise if there's not a date there45 datetime.datetime.strptime(46 could_be_a_date_value(account_object[field]), '%Y-%m-%d %H:%M:%S'47 )48def test_modifiedon_update(cdms_client, account_object):49 'ModifiedOn field doesnât change when update is called'50 initial_modifiedon = account_object['ModifiedOn']51 update_resp = cdms_client.update(...
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!!