I am a newbie and struggling to understand why “assert” cannot find my item. Details on the code and data below.
I would appreciate any help and thanks in advance.
=== code
`def logs():
with open(“assets/logdata.txt”, “r”) as file:
logdata = file.read()
# YOUR CODE HERE
import csv
pattern='''
(?P<host>.*)s
(- )
(?P<user_name>.*)s
[(?P<time>[^][]+)]s
"(?P<request>[^"]+)"
'''
dict_output = []
for item in re.finditer(pattern,logdata,re.VERBOSE):
details = str(item.groupdict())
dict_output.append(details)
return dict_output `
== outputs checks
assert len(logs()) == 979
one_item={'host': '146.204.224.152', 'user_name': 'feest6811', 'time': '21/Jun/2019:15:45:24 -0700', 'request': 'POST /incentivize HTTP/1.1'} assert one_item in logs(), "Sorry, this item should be in the log results, check your formating"
2M Project Management Consulta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1