짧은 이야기 : lettuce와 splinter를 사용하여 django app에 대한 기능 테스트를 작성하고 있습니다. 단계 호출에서 일부 동기화가 없어 시나리오가 실패합니다.lettuce + splinter와 django를 사용하여 기능 테스트 중 응답을 기다리십시오
질문 : 내 단계에 인공 대기 시간을 추가하지 않아도이 오류가 발생하지 않도록 할 수있는 방법이 있습니까?
긴 이야기 :. 시나리오 검사 기존 사용자가 로그인 할 수있는 경우
Scenario: User exists as admin
Given I access the url "/login/"
And The user "someuser" with password "something" exists as admin
When I fill username with "someuser" and password with "exists"
And I submit the form
Then I see the paragraph "You're successfully logged in!"
여기에 중요한 단계이다 : 나는 상추 기능을 수확 할 때, 무작위로
@step(r'I see the paragraph "(.*)"')
def see_paragraph(step, text):
assert text in world.browser.html
실패합니다.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/lettuce/core.py", line 143, in __call__
ret = self.function(self.step, *args, **kw)
File "/vagrant/src/enext/apps/auth/features/authentication-steps.py", line 21, in see_paragraph
assert text in world.browser.html
AssertionError
디버깅을 시도 할 때마다 응답을 인쇄하면 매번 작동하므로 오류를 재현 할 수없는 것으로 나타났습니다. 일시 중지를 추가하는 것도 트릭을 수행하는 것 같습니다. 이 테스트 데이터베이스 플러시와 관련된 것처럼
@step(r'I see the paragraph "(.*)"')
def see_paragraph(step, text):
# print world.browser.html.encode('utf-8')
# either the next or the previous line fixes it
time.sleep(0.3)
assert text in world.browser.html
은 처음에는 보였지만, 나뿐만 아니라 다른 시나리오와 플러시를 제거하고이 일어나고 있었다.
상추 없음 사랑입니까? 당분간 나는 적극적으로 기다릴 것입니다. 그러나 나는 여전히 이것에 관심이있다. 누구든지 새로운 것을 발견하면 – Felipe