Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyGis committed Jan 11, 2024
1 parent cdeb106 commit 6174f77
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is some test [Animaslsd] sdtri
3 changes: 3 additions & 0 deletions app/test_num.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
b = 5
a = 2
assert b < a
33 changes: 33 additions & 0 deletions app/test_regex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Content of "log.txt":
10.1.2.1 - car [01/Mar/2022:13:05:05 +0900] "GET /python HTTP/1.0" 200 2222
10.1.1.9 - bike [01/Mar/2022:13:05:10 +0900] "GET /python HTTP/1.0" 200 2222
Expected output:
01/Mar/2022:13:05:05 +0900
01/Mar/2022:13:05:10 +0900
"""
import re

def parse1():
for line in open("log.txt"):
print(line.split("[")[1].split("]")[0])
assert True

def parse2():
for line in open("log.txt", "r"):
print(line.split()[3].strip("[]"))
assert False

def parse3():
for line in open("log.txt", "r"):
print(" ".join(line.split("[" or "]")[3:5]))
assert True

print('Hello World')
parse3()


if __name__ == "__main__":
parse1()
parse3()

0 comments on commit 6174f77

Please sign in to comment.