Best Python code snippet using locust
test_includes.py
Source:test_includes.py
...52 [resource for resource in included if resource["type"] == "comments"]53 )54 expected_comment_count = single_entry.comments.count()55 assert comment_count == expected_comment_count, "Detail comment count is incorrect"56def test_dynamic_related_data_is_included(single_entry, entry_factory, client):57 entry_factory()58 response = client.get(59 reverse("entry-detail", kwargs={"pk": single_entry.pk}) + "?include=featured"60 )61 included = response.json().get("included")62 assert [x.get("type") for x in included] == [63 "entries"64 ], "Dynamic included types are incorrect"65 assert (66 len(included) == 167 ), "The dynamically included blog entries are of an incorrect count"68def test_dynamic_many_related_data_is_included(single_entry, entry_factory, client):69 entry_factory()70 response = client.get(71 reverse("entry-detail", kwargs={"pk": single_entry.pk}) + "?include=suggested"72 )73 included = response.json().get("included")74 assert included75 assert [x.get("type") for x in included] == [76 "entries"77 ], "Dynamic included types are incorrect"78def test_missing_field_not_included(author_bio_factory, author_factory, client):79 # First author does not have a bio80 author = author_factory(bio=None)81 response = client.get(reverse("author-detail", args=[author.pk]) + "?include=bio")82 assert "included" not in response.json()83 # Second author does84 author = author_factory()85 response = client.get(reverse("author-detail", args=[author.pk]) + "?include=bio")86 data = response.json()87 assert "included" in data88 assert len(data["included"]) == 189 assert data["included"][0]["attributes"]["body"] == author.bio.body90def test_deep_included_data_on_list(multiple_entries, client):91 response = client.get(92 reverse("entry-list") + "?include=comments,comments.author,"...
TYPES.py
Source:TYPES.py
1# Generated by h2py from /include/sys/types.h2_SYS_TYPES_H = 13# Included from features.h4_FEATURES_H = 15__USE_ANSI = 16__FAVOR_BSD = 17_ISOC9X_SOURCE = 18_POSIX_SOURCE = 19_POSIX_C_SOURCE = 199506L10_XOPEN_SOURCE = 50011_XOPEN_SOURCE_EXTENDED = 112_LARGEFILE64_SOURCE = 113_BSD_SOURCE = 114_SVID_SOURCE = 115_BSD_SOURCE = 116_SVID_SOURCE = 117__USE_ISOC9X = 118_POSIX_SOURCE = 119_POSIX_C_SOURCE = 220_POSIX_C_SOURCE = 199506L21__USE_POSIX = 122__USE_POSIX2 = 123__USE_POSIX199309 = 124__USE_POSIX199506 = 125__USE_XOPEN = 126__USE_XOPEN_EXTENDED = 127__USE_UNIX98 = 128_LARGEFILE_SOURCE = 129__USE_XOPEN_EXTENDED = 130__USE_LARGEFILE = 131__USE_LARGEFILE64 = 132__USE_FILE_OFFSET64 = 133__USE_MISC = 134__USE_BSD = 135__USE_SVID = 136__USE_GNU = 137__USE_REENTRANT = 138__STDC_IEC_559__ = 139__STDC_IEC_559_COMPLEX__ = 140__GNU_LIBRARY__ = 641__GLIBC__ = 242__GLIBC_MINOR__ = 143# Included from sys/cdefs.h44_SYS_CDEFS_H = 145def __PMT(args): return args46def __P(args): return args47def __PMT(args): return args48def __P(args): return ()49def __PMT(args): return ()50def __STRING(x): return #x51def __STRING(x): return "x"52def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname)53def __attribute__(xyz): return54__USE_EXTERN_INLINES = 155# Included from gnu/stubs.h56# Included from bits/types.h57_BITS_TYPES_H = 158__FD_SETSIZE = 102459def __FDELT(d): return ((d) / __NFDBITS)60# Included from bits/pthreadtypes.h61# Included from time.h62_TIME_H = 163# Included from bits/time.h64# Included from posix/time.h65# Included from posix/types.h66MAXHOSTNAMELEN = 6467FD_SETSIZE = 102468CLOCKS_PER_SEC = 100000069_BITS_TIME_H = 170CLOCKS_PER_SEC = 100000071CLK_TCK = 10072_STRUCT_TIMEVAL = 173CLK_TCK = CLOCKS_PER_SEC74__clock_t_defined = 175__time_t_defined = 176__timespec_defined = 177def __isleap(year): return \78__BIT_TYPES_DEFINED__ = 179# Included from endian.h80_ENDIAN_H = 181__LITTLE_ENDIAN = 123482__BIG_ENDIAN = 432183__PDP_ENDIAN = 341284# Included from bits/endian.h85__BYTE_ORDER = __LITTLE_ENDIAN86__FLOAT_WORD_ORDER = __BYTE_ORDER87LITTLE_ENDIAN = __LITTLE_ENDIAN88BIG_ENDIAN = __BIG_ENDIAN89PDP_ENDIAN = __PDP_ENDIAN90BYTE_ORDER = __BYTE_ORDER91# Included from sys/select.h92_SYS_SELECT_H = 193# Included from bits/select.h94def __FD_ZERO(fdsp): return \95def __FD_ZERO(set): return \96# Included from bits/sigset.h97_SIGSET_H_types = 198_SIGSET_H_fns = 199def __sigmask(sig): return \100def __sigemptyset(set): return \101def __sigfillset(set): return \102def __sigisemptyset(set): return \103FD_SETSIZE = __FD_SETSIZE104def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp)105# Included from sys/sysmacros.h106_SYS_SYSMACROS_H = 1107def major(dev): return ( (( (dev) >> 8) & 0xff))...
BadNeighbors.py
Source:BadNeighbors.py
1class BadNeighbors:2 def maxDonationsHelper(self, donations, i, first_included):3 if not self.memo.has_key((i, first_included)):4 if i == len(donations):5 return 06 if i == len(donations) - 1:7 return donations[i] if not first_included else 08 # include current donation9 v1_first_included = first_included10 if i == 0:11 v1_first_included = True12 v1 = donations[i] + self.maxDonationsHelper(donations, i + 2, v1_first_included)13 # exclude current donation14 v2 = self.maxDonationsHelper(donations, i + 1, first_included)15 self.memo[(i, first_included)] = max((v1, v2))16 return self.memo[(i, first_included)]17 def maxDonations(self, donations):18 self.memo = {}19 self.orig_len = len(donations)20 return self.maxDonationsHelper(donations, 0, False)21if __name__ == "__main__":22 print BadNeighbors().maxDonations([10, 3, 2, 5, 7, 8])23 print BadNeighbors().maxDonations([11, 15])24 print BadNeighbors().maxDonations([7, 7, 7, 7, 7, 7, 7])25 print BadNeighbors().maxDonations([1, 2, 3, 4, 5, 1, 2, 3, 4, 5 ])26 print BadNeighbors().maxDonations([94, 40, 49, 65, 21, 21, 106, 80, 92, 81,27 679, 4, 61, 6, 237, 12, 72, 74, 29, 95, 265, 35, 47, 1, 61, 397, 52, 72,...
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!!