Skip to content

Commit

Permalink
test: Convert some more test cases to pytest+pexpect
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Jul 11, 2018
1 parent 8884ceb commit 416fc05
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
2 changes: 2 additions & 0 deletions test/t/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SUBDIRS = unit

EXTRA_DIST = \
conftest.py \
test_2to3.py \
Expand Down
4 changes: 4 additions & 0 deletions test/t/unit/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
EXTRA_DIST = \
test_tilde.py \

all:
20 changes: 20 additions & 0 deletions test/t/unit/test_tilde.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from conftest import assert_bash_exec


@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=")
class TestUnitTilde(object):

def test_1(self, bash):
assert_bash_exec(bash, "_tilde >/dev/null")

def test_2(self, bash):
"""Test environment non-pollution, detected at teardown."""
assert_bash_exec(
bash,
'foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo')

def test_3(self, bash):
"""Test for https://bugs.debian.org/766163"""
assert_bash_exec(bash, '_tilde ~-o')
13 changes: 0 additions & 13 deletions test/unit/_tilde.exp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ proc teardown {} {
setup


set test "function should run without errors"
assert_bash_exec {_tilde > /dev/null} $test
sync_after_int

set test "function should not pollute environment"
# NOTE: A possible environment pollution is detected by assert_env_modified() in teardown()
assert_bash_exec {foo() { local aa="~"; _tilde "$aa"; }; foo; unset foo} $test
sync_after_int

set failed_find_unique_completion 0
assert_bash_exec {compgen -u} {} /@ users
if {![find_unique_completion_pair $users part full]} {
Expand All @@ -45,9 +36,5 @@ if {$failed_find_unique_completion} {
sync_after_int
}

# Debian #766163
assert_no_complete "_tilde ~-o"
sync_after_int


teardown

0 comments on commit 416fc05

Please sign in to comment.