Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore comments in --rerun-test-file #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions test/test_program_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def test_parse_test_runner_command_line_args_no_test_path(self):
test_program.parse_test_runner_command_line_args([], [])


def test_call(command):
proc = subprocess.Popen(command, stdout=subprocess.PIPE)
stdout, stderr = proc.communicate()
def test_call(command, stdin=None):
proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
stdout, stderr = proc.communicate(stdin)
if proc.returncode:
raise subprocess.CalledProcessError(proc.returncode, command)
return stdout.strip().decode('UTF-8')
Expand Down Expand Up @@ -147,6 +147,23 @@ def test_rerun_discovery_txt(self):
def test_rerun_discovery_json(self):
self.assert_rerun_discovery('json')

def test_rerun_ignores_comments_and_blank_lines(self):
output = test_call(
(sys.executable, '-m', 'testify.test_program', '-v', '--rerun-test-file', '-'),
stdin=(
b'test.test_suites_test SubDecoratedTestCase.test_thing\n'
b'# ignore this\n'
b'\n'
b'test.test_suites_test SubTestCase.test_thing\n'
),
)
output = re.sub(r'\b[0-9.]+s\b', '${TIME}', output)
assert_equal(output, '''\
test.test_suites_test SubDecoratedTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SubTestCase.test_thing ... ok in ${TIME}

PASSED. 2 tests / 2 cases: 2 passed, 0 failed. (Total test time ${TIME})''')

def test_run_testify_from_bin(self):
output = test_call(['bin/testify', 'testing_suite', '-v'])
assert_in(self.expected_tests, output)
Expand Down
2 changes: 1 addition & 1 deletion testify/test_rerunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def discover(self):
tests = [
constructor(test)
for test in tests.splitlines()
if test # Skip blank lines
if test and not test.startswith('#')
]

for class_path, tests in groupby(tests, lambda test: test[:2]):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35
envlist = py27,py37

[testenv]
passenv = TERM
Expand Down