Skip to content

Commit abd44fd

Browse files
authored
test: couple of nits (#10820)
* test: remove unused methods Two of the `FakeQuery` instances implemented a `.results` method that was never needed/exercised via tests, and can safely be removed. Signed-off-by: Mike Fiedler <[email protected]> * test: assert value on the exception location The inner assertion was getting "swallowed" during pytest's assertion rewriting, so the target location wasn't being validated. Moving the assert outside of the context manager provides us access to assert against the value. Outdenting this assertion provided the visibility that the assertion was incorrect, as the err.value is a Pyramid exception, which has a `location` property we are validating against. Refs: https://docs.pytest.org/en/6.2.x/assert.html#assertions-about-expected-exceptions Refs: https://docs.pylonsproject.org/projects/pyramid/en/latest/api/httpexceptions.html#pyramid.httpexceptions.HTTPSeeOther Signed-off-by: Mike Fiedler <[email protected]>
1 parent 384c843 commit abd44fd

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

tests/unit/utils/test_paginate.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ def __getitem__(self, range):
7979
self.range = range
8080
return self
8181

82-
@property
83-
def results(self):
84-
return pretend.stub(hits=pretend.stub(total=len(self.fake)))
85-
8682
def execute(self):
8783
return FakeResult(self.fake[self.range], len(self.fake))
8884

@@ -96,10 +92,6 @@ def __getitem__(self, range):
9692
self.range = range
9793
return self
9894

99-
@property
100-
def results(self):
101-
return pretend.stub(hits=pretend.stub(total=len(self.fake)))
102-
10395
def execute(self):
10496
return FakeResult6(self.fake[self.range], len(self.fake))
10597

tests/unit/utils/test_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_confirm_no_input():
6565

6666
with pytest.raises(HTTPSeeOther) as err:
6767
confirm_project(project, request, fail_route="fail_route")
68-
assert err.value == "/the-redirect"
68+
assert err.value.location == "/the-redirect"
6969

7070
assert request.route_path.calls == [call("fail_route", project_name="foobar")]
7171
assert request.session.flash.calls == [call("Confirm the request", queue="error")]
@@ -81,7 +81,7 @@ def test_confirm_incorrect_input():
8181

8282
with pytest.raises(HTTPSeeOther) as err:
8383
confirm_project(project, request, fail_route="fail_route")
84-
assert err.value == "/the-redirect"
84+
assert err.value.location == "/the-redirect"
8585

8686
assert request.route_path.calls == [call("fail_route", project_name="foobar")]
8787
assert request.session.flash.calls == [

0 commit comments

Comments
 (0)