From b51c1c3b8da92c670766fe2fec43f2332bfe7c70 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 9 Nov 2018 04:01:26 +0100 Subject: [PATCH] tests: fix equal_with_bash for .coverage files Fixes https://github.com/pytest-dev/pytest/issues/4162. --- testing/test_argcomplete.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/testing/test_argcomplete.py b/testing/test_argcomplete.py index 060cc2b49..046d69aa0 100644 --- a/testing/test_argcomplete.py +++ b/testing/test_argcomplete.py @@ -15,7 +15,7 @@ def equal_with_bash(prefix, ffc, fc, out=None): res_bash = set(fc(prefix)) retval = set(res) == res_bash if out: - out.write("equal_with_bash {} {}\n".format(retval, res)) + out.write("equal_with_bash({}) {} {}\n".format(prefix, retval, res)) if not retval: out.write(" python - bash: %s\n" % (set(res) - res_bash)) out.write(" bash - python: %s\n" % (res_bash - set(res))) @@ -91,13 +91,19 @@ class FilesCompleter(object): class TestArgComplete(object): @pytest.mark.skipif("sys.platform in ('win32', 'darwin')") - def test_compare_with_compgen(self): + def test_compare_with_compgen(self, tmpdir): from _pytest._argcomplete import FastFilesCompleter ffc = FastFilesCompleter() fc = FilesCompleter() - for x in ["/", "/d", "/data", "qqq", ""]: - assert equal_with_bash(x, ffc, fc, out=sys.stdout) + + with tmpdir.as_cwd(): + assert equal_with_bash("", ffc, fc, out=sys.stdout) + + tmpdir.ensure("data") + + for x in ["d", "data", "doesnotexist", ""]: + assert equal_with_bash(x, ffc, fc, out=sys.stdout) @pytest.mark.skipif("sys.platform in ('win32', 'darwin')") def test_remove_dir_prefix(self):