How do you configure PyCharm to run py.test with command-line options like -s?

24,445

D'oh, I figured it out after all:

enter image description here

You add it in the py.tests Options area of the Run/Edit configuration dialog.

Share:
24,445
Jason S
Author by

Jason S

Updated on January 10, 2020

Comments

  • Jason S
    Jason S over 4 years

    I figured out how to run py.test files from PyCharm:

    • Run/Debug configurations
    • in the Python tests category, click the "+" button to add a new configuration
    • choose py.test
    • enter the full path for the Target script and the working directory

    but I can't seem to add the -s option to allow my test script to run with standard output not captured and hidden. (I tried -s under interpreter options but it appears not to do anything.)

    How can I enable -s?

  • Tuukka Mustonen
    Tuukka Mustonen over 8 years
    To expand: if you want to configure defaults (so PyCharm auto-sets this when it auto-creates launch configs), there is separate Defaults category under Run/Debug Edit Configurations. Just set it there under Python tests > py.test.
  • Charles Merriam
    Charles Merriam about 8 years
    Still won't work for me. I'm trying to add ".py", which means to look in all py files for functions named test_. It gets swallowed by the test running scripts.
  • canyon289
    canyon289 almost 8 years
    Could you show how you got to this screen? I can't seem to find it. Edit Nevermind. Found it as well
  • zeal
    zeal almost 8 years
    How can we configure similar setup in Eclipse with PyDev plugin?
  • Jason S
    Jason S almost 8 years
    @zeal -- no idea, ask that as a separate question.
  • zeal
    zeal almost 8 years
    @JasonS - yep, raised it as separate question link - adding the link here for the benefit of getting some expert(s) attention!!!
  • sorin
    sorin almost 8 years
    This does not make much sense as is quite likely for the user to want to run pytest against its entire project, not a specific file. Target parameter seems to be mandatory. Still looking for a solution to this.
  • gzzzur
    gzzzur about 3 years
    Where is this magical Options area? I see: "Parameters" and "Additional Arguments". I see "Interpreter Options" - but that is for something else.