Skip to content

Commit

Permalink
Use shell=True to clear the terminal and use pytest.main directly to …
Browse files Browse the repository at this point in the history
…allow quoted arguments and avoid the security risks of using shell=True.

Discussion: dc066e2
  • Loading branch information
joeyespo committed Jun 14, 2015
1 parent e9361c3 commit abfd402
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pytest_watch/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import subprocess

import pytest
from colorama import Fore, Style
from watchdog.events import (
FileSystemEventHandler, FileModifiedEvent, FileCreatedEvent,
Expand Down Expand Up @@ -70,7 +71,7 @@ def on_any_event(self, event):
def run(self, summary=None):
"""Called when a file is changed to re-run the tests with py.test."""
if self.auto_clear:
subprocess.call(CLEAR_COMMAND)
subprocess.call(CLEAR_COMMAND, shell=True)
command = ' '.join(['py.test'] + self.args)
if summary and not self.auto_clear:
print()
Expand All @@ -88,7 +89,7 @@ def run(self, summary=None):
msg = ('Changes detected, rerunning: {}'
.format(highlight(command)))
print(STYLE_NORMAL + msg + Fore.RESET + Style.NORMAL)
exit_code = subprocess.call(['py.test'] + self.args)
exit_code = pytest.main(self.args)
passed = exit_code == 0

This comment has been minimized.

Copy link
@aldanor

aldanor Jun 14, 2015

Owner

Looks fine. It looks like you don't have to handle exceptions here since pytest.main always catches them so it's all good (https://bitbucket.org/pytest-dev/pytest/src/d6e31c7a2be21b51b813c024d5444d5a96e496ea/_pytest/config.py?at=default#cl-26).


# Beep if failed
Expand Down

1 comment on commit abfd402

@blueyed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference, this was reverted in 8d06657.

Please sign in to comment.