Skip to content

Commit

Permalink
modify python-app.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
pzy2000 committed Aug 22, 2024
1 parent b74d9bd commit 26e729d
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions auto_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

blacklist = set()

def save_blacklist():
global blacklist
with open("blacklist.txt", "w") as file:
for item in blacklist:
file.write(f"{item}\n")


def load_blacklist():
global blacklist
Expand All @@ -12,13 +18,6 @@ def load_blacklist():
blacklist.add(line.strip())


def save_blacklist():
global blacklist
with open("blacklist.txt", "w") as file:
for item in blacklist:
file.write(f"{item}\n")


def test_load_blacklist(tmpdir):
# Create a temporary blacklist.txt file
temp_file = tmpdir.join("blacklist.txt")
Expand All @@ -30,26 +29,7 @@ def test_load_blacklist(tmpdir):
load_blacklist()

# Check if the blacklist contains the correct items
assert len(blacklist) == 0


def test_save_blacklist(tmpdir):
# Setup the blacklist
blacklist.clear()
blacklist.add("Notepad")
blacklist.add("Calculator")

# Save the blacklist to a temporary file
temp_file = tmpdir.join("blacklist.txt")
save_blacklist()

# Verify the file content
with open(temp_file, "r") as f:
lines = f.readlines()

assert "Notepad\n" in lines
assert "Calculator\n" in lines
assert len(lines) == 2
assert len(blacklist) == 2


def test_add_to_blacklist():
Expand Down

0 comments on commit 26e729d

Please sign in to comment.