Skip to content

Replace most subprocess-spawning tests w/ dependency injection #25

@bitprophet

Description

@bitprophet

Many tests that are testing specific behavior of e.g run() take the easy route and call e.g. run('true', xxx), then introspect the result. This of course runs an actual subprocess and makes for a slower test suite ("only" ~4s right now, but it will keep growing.) Some even spawn a subprocess that spawns another subprocess! (E.g. the end of #21's new tests do this to get around pty stuff.)

Only the highest level sanity/integration tests really need to do this; the rest should be able to work with a dependency-injected mock object that behaves as needed w/o spawning a real subprocess.

Required:

  • Choose a mocking lib if we aren't already using one.
  • Change run to accept a runner argument & factor out the pexpect/subprocess using chunk of current function body.
  • Update most tests to do run(runner=<mock>).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions