Skip to content

Commit

Permalink
chore: Remove bare except
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 15, 2024
1 parent fbe0fe4 commit 10d9ad9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
15 changes: 3 additions & 12 deletions tests/commands/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def test_time_invalid(self):
@patch("yapw.methods.publish")
def test_source_invalid(self, publish):
with captured_stderr() as stderr:
try:
call_command("load", "--source", "nonexistent", "--note", "x", path("file.json"))
except Exception as e:
self.fail(f"Unexpected exception {e}")
call_command("load", "--source", "nonexistent", "--note", "x", path("file.json")) # no error

self.assertTrue(
"The --source argument can't be validated, because a Scrapyd URL is not configured in "
Expand Down Expand Up @@ -122,21 +119,15 @@ def test_source_invalid_scrapyd_force(self, spiders, publish):
spiders.return_value = ["france"]

with self.settings(SCRAPYD={"url": "http://example.com", "project": "kingfisher"}):
try:
call_command("load", "--source", "nonexistent", "--note", "x", "--force", path("file.json"))
except Exception as e:
self.fail(f"Unexpected exception {e}")
call_command("load", "--source", "nonexistent", "--note", "x", "--force", path("file.json")) # no error

@patch("process.scrapyd.spiders")
@patch("yapw.methods.publish")
def test_source_local(self, spiders, publish):
spiders.return_value = ["france"]

with self.settings(SCRAPYD={"url": "http://example.com", "project": "kingfisher"}):
try:
call_command("load", "--source", "france_local", "--note", "x", "--force", path("file.json"))
except Exception as e:
self.fail(f"Unexpected exception {e}")
call_command("load", "--source", "france_local", "--note", "x", "--force", path("file.json")) # no error

def test_unique_deleted_at(self):
source = collection(deleted_at="2001-01-01 00:00:00")
Expand Down
5 changes: 1 addition & 4 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ def test_clean_fields_existing_transform(self):
obj = collection(parent=source, transform_type="compile-releases")
obj.save()

try:
obj.clean_fields()
except Exception as e:
self.fail(f"Unexpected exception {e}")
obj.clean_fields() # no exception

def test_clean_fields_conditionally_mandatory(self):
source = collection()
Expand Down

0 comments on commit 10d9ad9

Please sign in to comment.