NYUCCL / psiTurk

An open platform for science on Amazon Mechanical Turk.
https://psiturk.org
MIT License
277 stars 140 forks source link

Failed test debug -p #451

Closed jacob-lee closed 3 years ago

jacob-lee commented 3 years ago

I resolved my issues getting pytest to run on my dev machine. When I did run it, I found that it was failing one test in test_do_commands in test_psiturk_shell with command ['debug -p']

>           assert not captured.err
E           AssertionError: assert not 'generating debug url using `ad_url` config var\n'
E            +  where 'generating debug url using `ad_url` config var\n' = CaptureResult(out='[\x01\x02psiTurk\x01\x02 server:\x01\x02off\x01\x02 mode:\x01\x02sdbx\x01\x02 #HITs:0]$ mode sandbo...bugKTTJBW&hitId=debugDPJK04&workerId=debugIIT1PF&mode=debug\n', err='generating debug url using `ad_url` config var\n').err

The issue is that calls to Cmd2.pfeedback in psiturk_shell.py were added recently:

try:
    base_url = self.config.get_ad_url()
    self.pfeedback('generating debug url using `ad_url` config var')
except PsiturkException:
    self.pfeedback('`ad_url_*` config vars not set; using Server '
                              'Parameters host and port vars.')
    host = self.config.get('Server Parameters', 'host')
    port = self.config.get('Server Parameters', 'port')
    base_url = f"http://{host}:{port}/ad"

Because get_shell in test_psiturk_shell creates a shell where the quiet parameter is set to False.

So the options are:

  1. ignore it,
  2. change the test,
  3. change Cmd2 to output non-essential feedback to stdout instead of stderr.
  4. remove call to pfeedback

I think #3 is best option. I've implemented in a PR request that I'll post momentarily.

deargle commented 3 years ago

Ah yeah, I wrote that test and then got distracted. But that test would have caught the earlier debug -p bug you found

deargle commented 3 years ago

Closed by #452