Skip to content

back to Reference (Gold) summary

Reference (Gold): jedi

Pytest Summary for test test

status count
passed 3814
failed 28
skipped 22
error 5
xfailed 5
total 3874
collected 3874

Failed pytests:

test_completion.py::test_file_path_completions[None-"test-None-expected1]

test_completion.py::test_file_path_completions[None-"test-None-expected1]
Script = functools.partial(, environment=)
file = None, code = '"test', column = None, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"'] == ['/']
E             
E             Left contains one more item: '_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[None-"test-4-expected2]

test_completion.py::test_file_path_completions[None-"test-4-expected2]
Script = functools.partial(, environment=)
file = None, code = '"test', column = 4, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-r"tes"-5-expected7]

test_completion.py::test_file_path_completions[example.py-r"tes"-5-expected7]
Script = functools.partial(, environment=)
file = 'example.py', code = 'r"tes"', column = 5, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-r"tes"-5-expected9]

example.py-r"tes"-5-expected9]
Script = functools.partial(, environment=)
file = 'test/example.py', code = 'r"tes"', column = 5, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

comp"-5-expected10]

comp"-5-expected10]
Script = functools.partial(, environment=)
file = 'test/example.py', code = 'r"test/comp"', column = 5, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

tes-None-expected13]

tes-None-expected13]
Script = functools.partial(, environment=)
file = 'example.py', code = 'rb"../testbed/tes', column = None
expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-r"""test-None-expected16]

test_completion.py::test_file_path_completions[example.py-r"""test-None-expected16]
Script = functools.partial(, environment=)
file = 'example.py', code = 'r"""test', column = None, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"""'] == ['/']
E             
E             Left contains one more item: '_output.txt"""'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-u"""tes\n-column18-expected18]

test_completion.py::test_file_path_completions[example.py-u"""tes\n-column18-expected18]
Script = functools.partial(, environment=)
file = 'example.py', code = 'u"""tes\n', column = 7, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"""'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"""'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st)-16-expected24]

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st)-16-expected24]
Script = functools.partial(, environment=)
file = 'example.py', code = 'x = f("te" + "st)', column = 16, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"'] == ['/']
E             
E             Left contains one more item: '_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st-16-expected25]

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st-16-expected25]
Script = functools.partial(, environment=)
file = 'example.py', code = 'x = f("te" + "st', column = 16, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"'] == ['/']
E             
E             Left contains one more item: '_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st"-16-expected26]

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st"-16-expected26]
Script = functools.partial(, environment=)
file = 'example.py', code = 'x = f("te" + "st"', column = 16, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['/', '_output.txt'] == ['/']
E             
E             Left contains one more item: '_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st")-16-expected27]

test_completion.py::test_file_path_completions[example.py-x = f("te" + "st")-16-expected27]
Script = functools.partial(, environment=)
file = 'example.py', code = 'x = f("te" + "st")', column = 16, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['/', '_output.txt'] == ['/']
E             
E             Left contains one more item: '_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-x = f("t" + "est")-16-expected28]

test_completion.py::test_file_path_completions[example.py-x = f("t" + "est")-16-expected28]
Script = functools.partial(, environment=)
file = 'example.py', code = 'x = f("t" + "est")', column = 16, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['/', '_output.txt'] == ['/']
E             
E             Left contains one more item: '_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_completion.py::test_file_path_completions[example.py-"test" + "-None-expected30]

test_completion.py::test_file_path_completions[example.py-"test" + "-None-expected30]
Script = functools.partial(, environment=)
file = 'example.py', code = '"test" + "', column = None, expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"'] == ['/']
E             
E             Left contains one more item: '_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test-None-expected31]

test-None-expected31]
Script = functools.partial(, environment=)
file = '/testbed/example.py'
code = 'from os.path import *\ndirname(__file__) + "/test', column = None
expected = ['/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['/', '_output.txt"'] == ['/']
E             
E             Left contains one more item: '_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin("tes-9-expected42]

example.py-from os.path import *\njoin("tes-9-expected42]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin("tes'
column = 9, expected = ['t"']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t"', 't_output.txt"'] == ['t"']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin('tes)-9-expected43]

example.py-from os.path import *\njoin('tes)-9-expected43]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = "from os.path import *\njoin('tes)"
column = 9, expected = ["t'"]

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ["t'", "t_output.txt'"] == ["t'"]
E             
E             Left contains one more item: "t_output.txt'"
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin(r"tes"-10-expected44]

example.py-from os.path import *\njoin(r"tes"-10-expected44]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin(r"tes"'
column = 10, expected = ['t']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t', 't_output.txt'] == ['t']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin("""tes""")-11-expected45]

example.py-from os.path import *\njoin("""tes""")-11-expected45]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py'
code = 'from os.path import *\njoin("""tes""")', column = 11, expected = ['t']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t', 't_output.txt'] == ['t']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin["tes-9-expected46]

example.py-from os.path import *\njoin["tes-9-expected46]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin["tes'
column = 9, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin["tes"-9-expected47]

example.py-from os.path import *\njoin["tes"-9-expected47]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin["tes"'
column = 9, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin["tes"]-9-expected48]

example.py-from os.path import *\njoin["tes"]-9-expected48]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin["tes"]'
column = 9, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin(["tes-10-expected57]

example.py-from os.path import *\njoin(["tes-10-expected57]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin(["tes'
column = 10, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           assert ['t/', 't_output.txt"'] == ['t/']
E             
E             Left contains one more item: 't_output.txt"'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin(["tes"]-10-expected58]

example.py-from os.path import *\njoin(["tes"]-10-expected58]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin(["tes"]'
column = 10, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

example.py-from os.path import *\njoin(["tes"])-10-expected59]

example.py-from os.path import *\njoin(["tes"])-10-expected59]
Script = functools.partial(, environment=)
file = '/testbed/test/example.py', code = 'from os.path import *\njoin(["tes"])'
column = 10, expected = ['t/']

    @pytest.mark.parametrize(
        'file, code, column, expected', [
            # General tests / relative paths
            (None, '"comp', None, []),  # No files like comp
            (None, '"test', None, [s]),
            (None, '"test', 4, ['t' + s]),
            ('example.py', '"test%scomp' % s, None, ['letion' + s]),
            ('example.py', 'r"comp"', None, []),
            ('example.py', 'r"tes"', None, []),
            ('example.py', '1 + r"tes"', None, []),
            ('example.py', 'r"tes"', 5, ['t' + s]),
            ('example.py', 'r" tes"', 6, []),
            ('test%sexample.py' % se, 'r"tes"', 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 5, ['t' + s]),
            ('test%sexample.py' % se, 'r"test%scomp"' % s, 11, ['letion' + s]),
            ('test%sexample.py' % se, '"%s"' % join('test', 'completion', 'basi'), 21, ['c.py']),
            ('example.py', 'rb"' + join('..', current_dirname, 'tes'), None, ['t' + s]),

            # Absolute paths
            (None, f'"{root_dir.joinpath("test", "test_ca")}', None, ['che.py"']),
            (None, f'"{root_dir.joinpath("test", "test_ca")}"', len(str(root_dir)) + 14, ['che.py']),

            # Longer quotes
            ('example.py', 'r"""test', None, [s]),
            ('example.py', 'r"""\ntest', None, []),
            ('example.py', 'u"""tes\n', (1, 7), ['t' + s]),
            ('example.py', '"""test%stest_cache.p"""' % s, 20, ['y']),
            ('example.py', '"""test%stest_cache.p"""' % s, 19, ['py"""']),

            # Adding
            ('example.py', '"test" + "%stest_cac' % se, None, ['he.py"']),
            ('example.py', '"test" + "%s" + "test_cac' % se, None, ['he.py"']),
            ('example.py', 'x = 1 + "test', None, []),
            ('example.py', 'x = f("te" + "st)', 16, [s]),
            ('example.py', 'x = f("te" + "st', 16, [s]),
            ('example.py', 'x = f("te" + "st"', 16, [s]),
            ('example.py', 'x = f("te" + "st")', 16, [s]),
            ('example.py', 'x = f("t" + "est")', 16, [s]),
            ('example.py', 'x = f(b"t" + "est")', 17, []),
            ('example.py', '"test" + "', None, [s]),

            # __file__
            (f1, os_path + 'dirname(__file__) + "%stest' % s, None, [s]),
            (f2, os_path + 'dirname(__file__) + "%stest_ca' % se, None, ['che.py"']),
            (f2, os_path + 'dirname(abspath(__file__)) + sep + "test_ca', None, ['che.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion") + sep + "basi', None, ['c.py"']),
            (f2, os_path + 'join("test", "completion") + sep + "basi', None, ['c.py"']),

            # inside join
            (f2, os_path + 'join(dirname(__file__), "completion", "basi', None, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 43, ['c.py"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 43, ['c.py']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 35, ['']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi)', 33, ['on"']),
            (f2, os_path + 'join(dirname(__file__), "completion", "basi")', 33, ['on"']),

            # join with one argument. join will not get inferred and the result is
            # that directories and in a slash. This is unfortunate, but doesn't
            # really matter.
            (f2, os_path + 'join("tes', 9, ['t"']),
            (f2, os_path + 'join(\'tes)', 9, ["t'"]),
            (f2, os_path + 'join(r"tes"', 10, ['t']),
            (f2, os_path + 'join("""tes""")', 11, ['t']),

            # Almost like join but not really
            (f2, os_path + 'join["tes', 9, ['t' + s]),
            (f2, os_path + 'join["tes"', 9, ['t' + s]),
            (f2, os_path + 'join["tes"]', 9, ['t' + s]),
            (f2, os_path + 'join[dirname(__file__), "completi', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"', 33, []),
            (f2, os_path + 'join[dirname(__file__), "completi"]', 33, []),

            # With full paths
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi', 49, ['on"']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi"', 49, ['on']),
            (f2, 'import os\nos.path.join(os.path.dirname(__file__), "completi")', 49, ['on']),

            # With alias
            (f2, 'import os.path as p as p\np.join(p.dirname(__file__), "completi', None, ['on"']),
            (f2, 'from os.path import dirname, join as j\nj(dirname(__file__), "completi',
             None, ['on"']),

            # Trying to break it
            (f2, os_path + 'join(["tes', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"]', 10, ['t' + s]),
            (f2, os_path + 'join(["tes"])', 10, ['t' + s]),
            (f2, os_path + 'join("test", "test_cac" + x,', 22, ['he.py']),

            # GH #1528
            (f2, "'a' 'b'", 4, Ellipsis),
        ]
    )
    def test_file_path_completions(Script, file, code, column, expected):
        line = None
        if isinstance(column, tuple):
            line, column = column
        comps = Script(code, path=file).complete(line=line, column=column)
        if expected is Ellipsis:
            assert len(comps) > 100  # This is basically global completions.
        else:
>           assert [c.complete for c in comps] == expected
E           AssertionError: assert ['t/', 't_output.txt'] == ['t/']
E             
E             Left contains one more item: 't_output.txt'
E             Use -v to get more diff

test/test_api/test_completion.py:297: AssertionError

test_environment.py::test_working_venv

test_environment.py::test_working_venv
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-0'), _retention_count=3, _retention_policy='all'))
environment = 

    @pytest.fixture(scope='session')
    def venv_path(tmpdir_factory, environment):
        if isinstance(environment, InterpreterEnvironment):
            # The environment can be a tox virtualenv environment which we don't
            # want, so use the system environment.
            environment = get_system_environment(
                '.'.join(str(x) for x in environment.version_info[:2])
            )

        tmpdir = tmpdir_factory.mktemp('venv_path')
        dirname = os.path.join(tmpdir.strpath, 'venv')

        # We cannot use the Python from tox because tox creates virtualenvs and
        # they have different site.py files that work differently than the default
        # ones. Instead, we find the real Python executable by printing the value
        # of sys.base_prefix or sys.real_prefix if we are in a virtualenv.
        output = subprocess.check_output([
            environment.executable, "-c",
            "import sys; "
            "print(sys.real_prefix if hasattr(sys, 'real_prefix') else sys.base_prefix)"
        ])
        prefix = output.rstrip().decode('utf8')
        if os.name == 'nt':
            executable_path = os.path.join(prefix, 'python')
        else:
            executable_name = os.path.basename(environment.executable)
            executable_path = os.path.join(prefix, 'bin', executable_name)

        return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
>       assert return_code == 0, return_code
E       AssertionError: 1
E       assert 1 == 0

test/conftest.py:128: AssertionError

test_environment.py::test_scanning_venvs

test_environment.py::test_scanning_venvs
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-0'), _retention_count=3, _retention_policy='all'))
environment = 

    @pytest.fixture(scope='session')
    def venv_path(tmpdir_factory, environment):
        if isinstance(environment, InterpreterEnvironment):
            # The environment can be a tox virtualenv environment which we don't
            # want, so use the system environment.
            environment = get_system_environment(
                '.'.join(str(x) for x in environment.version_info[:2])
            )

        tmpdir = tmpdir_factory.mktemp('venv_path')
        dirname = os.path.join(tmpdir.strpath, 'venv')

        # We cannot use the Python from tox because tox creates virtualenvs and
        # they have different site.py files that work differently than the default
        # ones. Instead, we find the real Python executable by printing the value
        # of sys.base_prefix or sys.real_prefix if we are in a virtualenv.
        output = subprocess.check_output([
            environment.executable, "-c",
            "import sys; "
            "print(sys.real_prefix if hasattr(sys, 'real_prefix') else sys.base_prefix)"
        ])
        prefix = output.rstrip().decode('utf8')
        if os.name == 'nt':
            executable_path = os.path.join(prefix, 'python')
        else:
            executable_name = os.path.basename(environment.executable)
            executable_path = os.path.join(prefix, 'bin', executable_name)

        return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
>       assert return_code == 0, return_code
E       AssertionError: 1
E       assert 1 == 0

test/conftest.py:128: AssertionError

test_environment.py::test_create_environment_venv_path

test_environment.py::test_create_environment_venv_path
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-0'), _retention_count=3, _retention_policy='all'))
environment = 

    @pytest.fixture(scope='session')
    def venv_path(tmpdir_factory, environment):
        if isinstance(environment, InterpreterEnvironment):
            # The environment can be a tox virtualenv environment which we don't
            # want, so use the system environment.
            environment = get_system_environment(
                '.'.join(str(x) for x in environment.version_info[:2])
            )

        tmpdir = tmpdir_factory.mktemp('venv_path')
        dirname = os.path.join(tmpdir.strpath, 'venv')

        # We cannot use the Python from tox because tox creates virtualenvs and
        # they have different site.py files that work differently than the default
        # ones. Instead, we find the real Python executable by printing the value
        # of sys.base_prefix or sys.real_prefix if we are in a virtualenv.
        output = subprocess.check_output([
            environment.executable, "-c",
            "import sys; "
            "print(sys.real_prefix if hasattr(sys, 'real_prefix') else sys.base_prefix)"
        ])
        prefix = output.rstrip().decode('utf8')
        if os.name == 'nt':
            executable_path = os.path.join(prefix, 'python')
        else:
            executable_name = os.path.basename(environment.executable)
            executable_path = os.path.join(prefix, 'bin', executable_name)

        return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
>       assert return_code == 0, return_code
E       AssertionError: 1
E       assert 1 == 0

test/conftest.py:128: AssertionError

test_environment.py::test_changing_venv

test_environment.py::test_changing_venv
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-0'), _retention_count=3, _retention_policy='all'))
environment = 

    @pytest.fixture(scope='session')
    def venv_path(tmpdir_factory, environment):
        if isinstance(environment, InterpreterEnvironment):
            # The environment can be a tox virtualenv environment which we don't
            # want, so use the system environment.
            environment = get_system_environment(
                '.'.join(str(x) for x in environment.version_info[:2])
            )

        tmpdir = tmpdir_factory.mktemp('venv_path')
        dirname = os.path.join(tmpdir.strpath, 'venv')

        # We cannot use the Python from tox because tox creates virtualenvs and
        # they have different site.py files that work differently than the default
        # ones. Instead, we find the real Python executable by printing the value
        # of sys.base_prefix or sys.real_prefix if we are in a virtualenv.
        output = subprocess.check_output([
            environment.executable, "-c",
            "import sys; "
            "print(sys.real_prefix if hasattr(sys, 'real_prefix') else sys.base_prefix)"
        ])
        prefix = output.rstrip().decode('utf8')
        if os.name == 'nt':
            executable_path = os.path.join(prefix, 'python')
        else:
            executable_name = os.path.basename(environment.executable)
            executable_path = os.path.join(prefix, 'bin', executable_name)

        return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
>       assert return_code == 0, return_code
E       AssertionError: 1
E       assert 1 == 0

test/conftest.py:128: AssertionError

test_imports.py::test_flask_ext[import flask.ext.foo; flask.ext.foo.-Foo]

test_imports.py::test_flask_ext[import flask.ext.foo; flask.ext.foo.-Foo]
Script = functools.partial(, environment=)
code = 'import flask.ext.foo; flask.ext.foo.', name = 'Foo'

    @pytest.mark.parametrize("code,name", [
        ("from flask.ext import foo; foo.", "Foo"),  # flask_foo.py
        ("from flask.ext import bar; bar.", "Bar"),  # flaskext/bar.py
        ("from flask.ext import baz; baz.", "Baz"),  # flask_baz/__init__.py
        ("from flask.ext import moo; moo.", "Moo"),  # flaskext/moo/__init__.py
        ("from flask.ext.", "foo"),
        ("from flask.ext.", "bar"),
        ("from flask.ext.", "baz"),
        ("from flask.ext.", "moo"),
        pytest.param("import flask.ext.foo; flask.ext.foo.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.bar; flask.ext.bar.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.baz; flask.ext.baz.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.moo; flask.ext.moo.", "Foo", marks=pytest.mark.xfail),
    ])
    def test_flask_ext(Script, code, name):
        """flask.ext.foo is really imported from flaskext.foo or flask_foo.
        """
        path = get_example_dir('flask-site-packages')
        completions = Script(code, project=Project('.', sys_path=[path])).complete()
>       assert name in [c.name for c in completions]
E       AssertionError: assert 'Foo' in []

test/test_inference/test_imports.py:169: AssertionError

test_imports.py::test_flask_ext[import flask.ext.bar; flask.ext.bar.-Foo]

test_imports.py::test_flask_ext[import flask.ext.bar; flask.ext.bar.-Foo]
Script = functools.partial(, environment=)
code = 'import flask.ext.bar; flask.ext.bar.', name = 'Foo'

    @pytest.mark.parametrize("code,name", [
        ("from flask.ext import foo; foo.", "Foo"),  # flask_foo.py
        ("from flask.ext import bar; bar.", "Bar"),  # flaskext/bar.py
        ("from flask.ext import baz; baz.", "Baz"),  # flask_baz/__init__.py
        ("from flask.ext import moo; moo.", "Moo"),  # flaskext/moo/__init__.py
        ("from flask.ext.", "foo"),
        ("from flask.ext.", "bar"),
        ("from flask.ext.", "baz"),
        ("from flask.ext.", "moo"),
        pytest.param("import flask.ext.foo; flask.ext.foo.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.bar; flask.ext.bar.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.baz; flask.ext.baz.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.moo; flask.ext.moo.", "Foo", marks=pytest.mark.xfail),
    ])
    def test_flask_ext(Script, code, name):
        """flask.ext.foo is really imported from flaskext.foo or flask_foo.
        """
        path = get_example_dir('flask-site-packages')
        completions = Script(code, project=Project('.', sys_path=[path])).complete()
>       assert name in [c.name for c in completions]
E       AssertionError: assert 'Foo' in []

test/test_inference/test_imports.py:169: AssertionError

test_imports.py::test_flask_ext[import flask.ext.baz; flask.ext.baz.-Foo]

test_imports.py::test_flask_ext[import flask.ext.baz; flask.ext.baz.-Foo]
Script = functools.partial(, environment=)
code = 'import flask.ext.baz; flask.ext.baz.', name = 'Foo'

    @pytest.mark.parametrize("code,name", [
        ("from flask.ext import foo; foo.", "Foo"),  # flask_foo.py
        ("from flask.ext import bar; bar.", "Bar"),  # flaskext/bar.py
        ("from flask.ext import baz; baz.", "Baz"),  # flask_baz/__init__.py
        ("from flask.ext import moo; moo.", "Moo"),  # flaskext/moo/__init__.py
        ("from flask.ext.", "foo"),
        ("from flask.ext.", "bar"),
        ("from flask.ext.", "baz"),
        ("from flask.ext.", "moo"),
        pytest.param("import flask.ext.foo; flask.ext.foo.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.bar; flask.ext.bar.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.baz; flask.ext.baz.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.moo; flask.ext.moo.", "Foo", marks=pytest.mark.xfail),
    ])
    def test_flask_ext(Script, code, name):
        """flask.ext.foo is really imported from flaskext.foo or flask_foo.
        """
        path = get_example_dir('flask-site-packages')
        completions = Script(code, project=Project('.', sys_path=[path])).complete()
>       assert name in [c.name for c in completions]
E       AssertionError: assert 'Foo' in []

test/test_inference/test_imports.py:169: AssertionError

test_imports.py::test_flask_ext[import flask.ext.moo; flask.ext.moo.-Foo]

test_imports.py::test_flask_ext[import flask.ext.moo; flask.ext.moo.-Foo]
Script = functools.partial(, environment=)
code = 'import flask.ext.moo; flask.ext.moo.', name = 'Foo'

    @pytest.mark.parametrize("code,name", [
        ("from flask.ext import foo; foo.", "Foo"),  # flask_foo.py
        ("from flask.ext import bar; bar.", "Bar"),  # flaskext/bar.py
        ("from flask.ext import baz; baz.", "Baz"),  # flask_baz/__init__.py
        ("from flask.ext import moo; moo.", "Moo"),  # flaskext/moo/__init__.py
        ("from flask.ext.", "foo"),
        ("from flask.ext.", "bar"),
        ("from flask.ext.", "baz"),
        ("from flask.ext.", "moo"),
        pytest.param("import flask.ext.foo; flask.ext.foo.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.bar; flask.ext.bar.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.baz; flask.ext.baz.", "Foo", marks=pytest.mark.xfail),
        pytest.param("import flask.ext.moo; flask.ext.moo.", "Foo", marks=pytest.mark.xfail),
    ])
    def test_flask_ext(Script, code, name):
        """flask.ext.foo is really imported from flaskext.foo or flask_foo.
        """
        path = get_example_dir('flask-site-packages')
        completions = Script(code, project=Project('.', sys_path=[path])).complete()
>       assert name in [c.name for c in completions]
E       AssertionError: assert 'Foo' in []

test/test_inference/test_imports.py:169: AssertionError

test_precedence.py::test_equals[... == ...]

test_precedence.py::test_equals[... == ...]
Script = functools.partial(, environment=)
environment = , source = '... == ...'

    @pytest.mark.parametrize('source', [
        pytest.param('1 == 1'),
        pytest.param('1.0 == 1'),
        # Unfortunately for now not possible, because it's a typeshed object.
        pytest.param('... == ...', marks=pytest.mark.xfail),
    ])
    def test_equals(Script, environment, source):
        script = Script(source)
        node = script._module_node.children[0]
>       first, = script._get_module_context().infer_node(node)
E       ValueError: too many values to unpack (expected 1)

test/test_inference/test_precedence.py:15: ValueError

test_sys_path.py::test_venv_and_pths

test_sys_path.py::test_venv_and_pths
tmpdir_factory = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=, _basetemp=PosixPath('/tmp/pytest-of-root/pytest-0'), _retention_count=3, _retention_policy='all'))
environment = 

    @pytest.fixture(scope='session')
    def venv_path(tmpdir_factory, environment):
        if isinstance(environment, InterpreterEnvironment):
            # The environment can be a tox virtualenv environment which we don't
            # want, so use the system environment.
            environment = get_system_environment(
                '.'.join(str(x) for x in environment.version_info[:2])
            )

        tmpdir = tmpdir_factory.mktemp('venv_path')
        dirname = os.path.join(tmpdir.strpath, 'venv')

        # We cannot use the Python from tox because tox creates virtualenvs and
        # they have different site.py files that work differently than the default
        # ones. Instead, we find the real Python executable by printing the value
        # of sys.base_prefix or sys.real_prefix if we are in a virtualenv.
        output = subprocess.check_output([
            environment.executable, "-c",
            "import sys; "
            "print(sys.real_prefix if hasattr(sys, 'real_prefix') else sys.base_prefix)"
        ])
        prefix = output.rstrip().decode('utf8')
        if os.name == 'nt':
            executable_path = os.path.join(prefix, 'python')
        else:
            executable_name = os.path.basename(environment.executable)
            executable_path = os.path.join(prefix, 'bin', executable_name)

        return_code = subprocess.call([executable_path, '-m', 'venv', dirname])
>       assert return_code == 0, return_code
E       AssertionError: 1
E       assert 1 == 0

test/conftest.py:128: AssertionError

test_utils.py::TestSetupReadline::test_colorama

test_utils.py::TestSetupReadline::test_colorama
self = 

    def test_colorama(self):
        """
        Only test it if colorama library is available.

        This module is being tested because it uses ``setattr`` at some point,
        which Jedi doesn't understand, but it should still work in the REPL.
        """
        try:
            # if colorama is installed
            import colorama
        except ImportError:
            pass
        else:
            self.namespace.colorama = colorama
>           assert self.complete('colorama')
E           AssertionError: assert []
E            +  where [] = complete('colorama')
E            +    where complete = .complete

test/test_utils.py:113: AssertionError

test_utils.py::TestSetupReadline::test_modules

test_utils.py::TestSetupReadline::test_modules
self = 

    def test_modules(self):
        import sys
        import os
        self.namespace.sys = sys
        self.namespace.os = os

        try:
>           assert self.complete('os.path.join') == ['os.path.join']
E           AssertionError: assert [] == ['os.path.join']
E             
E             Right contains one more item: 'os.path.join'
E             Use -v to get more diff

test/test_utils.py:54: AssertionError

test_utils.py::TestSetupReadline::test_preexisting_values

test_utils.py::TestSetupReadline::test_preexisting_values
self = 

    def test_preexisting_values(self):
        self.namespace.a = range(10)
>       assert set(self.complete('a.')) == {'a.' + n for n in dir(range(1))}
E       AssertionError: assert set() == {'a.__bool__'...__doc__', ...}
E         
E         Extra items in the right set:
E         'a.step'
E         'a.__class__'
E         'a.__le__'
E         'a.count'
E         'a.__len__'...
E         
E         ...Full output truncated (30 lines hidden), use '-vv' to show

test/test_utils.py:96: AssertionError

Patch diff

diff --git a/jedi/_compatibility.py b/jedi/_compatibility.py
index 976a96ed..13a74b7b 100644
--- a/jedi/_compatibility.py
+++ b/jedi/_compatibility.py
@@ -5,3 +5,28 @@ different Python versions.
 import errno
 import sys
 import pickle
+
+
+def pickle_load(file):
+    try:
+        return pickle.load(file)
+    # Python on Windows don't throw EOF errors for pipes. So reraise them with
+    # the correct type, which is caught upwards.
+    except OSError:
+        if sys.platform == 'win32':
+            raise EOFError()
+        raise
+
+
+def pickle_dump(data, file, protocol):
+    try:
+        pickle.dump(data, file, protocol)
+        # On Python 3.3 flush throws sometimes an error even though the writing
+        # operation should be completed.
+        file.flush()
+    # Python on Windows don't throw EPIPE errors for pipes. So reraise them with
+    # the correct type and error number.
+    except OSError:
+        if sys.platform == 'win32':
+            raise IOError(errno.EPIPE, "Broken pipe")
+        raise
diff --git a/jedi/api/classes.py b/jedi/api/classes.py
index 04b944e5..7054788e 100644
--- a/jedi/api/classes.py
+++ b/jedi/api/classes.py
@@ -16,7 +16,9 @@ the interesting information about all operations.
 import re
 from pathlib import Path
 from typing import Optional
+
 from parso.tree import search_ancestor
+
 from jedi import settings
 from jedi import debug
 from jedi.inference.utils import unite
@@ -31,6 +33,10 @@ from jedi.api import completion_cache
 from jedi.api.helpers import filter_follow_imports


+def _sort_names_by_start_pos(names):
+    return sorted(names, key=lambda s: s.start_pos or (0, 0))
+
+
 def defined_names(inference_state, value):
     """
     List sub-definitions (e.g., methods in class).
@@ -38,20 +44,41 @@ def defined_names(inference_state, value):
     :type scope: Scope
     :rtype: list of Name
     """
-    pass
+    try:
+        context = value.as_context()
+    except HasNoContext:
+        return []
+    filter = next(context.get_filters())
+    names = [name for name in filter.values()]
+    return [Name(inference_state, n) for n in _sort_names_by_start_pos(names)]
+
+
+def _values_to_definitions(values):
+    return [Name(c.inference_state, c.name) for c in values]


 class BaseName:
     """
     The base class for all definitions, completions and signatures.
     """
-    _mapping = {'posixpath': 'os.path', 'riscospath': 'os.path', 'ntpath':
-        'os.path', 'os2emxpath': 'os.path', 'macpath': 'os.path',
-        'genericpath': 'os.path', 'posix': 'os', '_io': 'io', '_functools':
-        'functools', '_collections': 'collections', '_socket': 'socket',
-        '_sqlite3': 'sqlite3'}
-    _tuple_mapping = dict((tuple(k.split('.')), v) for k, v in {
-        'argparse._ActionsContainer': 'argparse.ArgumentParser'}.items())
+    _mapping = {
+        'posixpath': 'os.path',
+        'riscospath': 'os.path',
+        'ntpath': 'os.path',
+        'os2emxpath': 'os.path',
+        'macpath': 'os.path',
+        'genericpath': 'os.path',
+        'posix': 'os',
+        '_io': 'io',
+        '_functools': 'functools',
+        '_collections': 'collections',
+        '_socket': 'socket',
+        '_sqlite3': 'sqlite3',
+    }
+
+    _tuple_mapping = dict((tuple(k.split('.')), v) for (k, v) in {
+        'argparse._ActionsContainer': 'argparse.ArgumentParser',
+    }.items())

     def __init__(self, inference_state, name):
         self._inference_state = inference_state
@@ -61,12 +88,26 @@ class BaseName:
         """
         self.is_keyword = isinstance(self._name, KeywordName)

+    @memoize_method
+    def _get_module_context(self):
+        # This can take a while to complete, because in the worst case of
+        # imports (consider `import a` completions), we need to load all
+        # modules starting with a first.
+        return self._name.get_root_context()
+
     @property
-    def module_path(self) ->Optional[Path]:
+    def module_path(self) -> Optional[Path]:
         """
         Shows the file path of a module. e.g. ``/usr/lib/python3.9/os.py``
         """
-        pass
+        module = self._get_module_context()
+        if module.is_stub() or not module.is_compiled():
+            # Compiled modules should not return a module path even if they
+            # have one.
+            path: Optional[Path] = self._get_module_context().py__file__()
+            return path
+
+        return None

     @property
     def name(self):
@@ -77,7 +118,7 @@ class BaseName:

         :rtype: str or None
         """
-        pass
+        return self._name.get_public_name()

     @property
     def type(self):
@@ -136,7 +177,19 @@ class BaseName:
         ``param``, ``path``, ``keyword``, ``property`` and ``statement``.

         """
-        pass
+        tree_name = self._name.tree_name
+        resolve = False
+        if tree_name is not None:
+            # TODO move this to their respective names.
+            definition = tree_name.get_definition()
+            if definition is not None and definition.type == 'import_from' and \
+                    tree_name.is_definition():
+                resolve = True
+
+        if isinstance(self._name, SubModuleName) or resolve:
+            for value in self._name.infer():
+                return value.api_type
+        return self._name.api_type

     @property
     def module_name(self):
@@ -151,23 +204,32 @@ class BaseName:
         >>> print(d.module_name)  # doctest: +ELLIPSIS
         json
         """
-        pass
+        return self._get_module_context().py__name__()

     def in_builtin_module(self):
         """
         Returns True, if this is a builtin module.
         """
-        pass
+        value = self._get_module_context().get_value()
+        if isinstance(value, StubModuleValue):
+            return any(v.is_compiled() for v in value.non_stub_value_set)
+        return value.is_compiled()

     @property
     def line(self):
         """The line where the definition occurs (starting with 1)."""
-        pass
+        start_pos = self._name.start_pos
+        if start_pos is None:
+            return None
+        return start_pos[0]

     @property
     def column(self):
         """The column where the definition occurs (starting with 0)."""
-        pass
+        start_pos = self._name.start_pos
+        if start_pos is None:
+            return None
+        return start_pos[1]

     def get_definition_start_position(self):
         """
@@ -176,7 +238,12 @@ class BaseName:

         :rtype: Optional[Tuple[int, int]]
         """
-        pass
+        if self._name.tree_name is None:
+            return None
+        definition = self._name.tree_name.get_definition()
+        if definition is None:
+            return self._name.start_pos
+        return definition.start_pos

     def get_definition_end_position(self):
         """
@@ -185,16 +252,26 @@ class BaseName:

         :rtype: Optional[Tuple[int, int]]
         """
-        pass
+        if self._name.tree_name is None:
+            return None
+        definition = self._name.tree_name.get_definition()
+        if definition is None:
+            return self._name.tree_name.end_pos
+        if self.type in ("function", "class"):
+            last_leaf = definition.get_last_leaf()
+            if last_leaf.type == "newline":
+                return last_leaf.get_previous_leaf().end_pos
+            return last_leaf.end_pos
+        return definition.end_pos

     def docstring(self, raw=False, fast=True):
-        """
+        r"""
         Return a document string for this completion object.

         Example:

         >>> from jedi import Script
-        >>> source = '''\\
+        >>> source = '''\
         ... def f(a, b=1):
         ...     "Document for function f."
         ... '''
@@ -218,7 +295,26 @@ class BaseName:
             the ``foo.docstring(fast=False)`` on every object, because it
             parses all libraries starting with ``a``.
         """
-        pass
+        if isinstance(self._name, ImportName) and fast:
+            return ''
+        doc = self._get_docstring()
+        if raw:
+            return doc
+
+        signature_text = self._get_docstring_signature()
+        if signature_text and doc:
+            return signature_text + '\n\n' + doc
+        else:
+            return signature_text + doc
+
+    def _get_docstring(self):
+        return self._name.py__doc__()
+
+    def _get_docstring_signature(self):
+        return '\n'.join(
+            signature.to_string()
+            for signature in self._get_signatures(for_docstring=True)
+        )

     @property
     def description(self):
@@ -249,7 +345,25 @@ class BaseName:
         'class C'

         """
-        pass
+        typ = self.type
+        tree_name = self._name.tree_name
+        if typ == 'param':
+            return typ + ' ' + self._name.to_string()
+        if typ in ('function', 'class', 'module', 'instance') or tree_name is None:
+            if typ == 'function':
+                # For the description we want a short and a pythonic way.
+                typ = 'def'
+            return typ + ' ' + self._name.get_public_name()
+
+        definition = tree_name.get_definition(include_setitem=True) or tree_name
+        # Remove the prefix, because that's not what we want for get_code
+        # here.
+        txt = definition.get_code(include_prefix=False)
+        # Delete comments:
+        txt = re.sub(r'#[^\n]+\n', ' ', txt)
+        # Delete multi spaces/newlines
+        txt = re.sub(r'\s+', ' ', txt).strip()
+        return txt

     @property
     def full_name(self):
@@ -275,24 +389,44 @@ class BaseName:
         be ``<module 'posixpath' ...>```. However most users find the latter
         more practical.
         """
-        pass
+        if not self._name.is_value_name:
+            return None
+
+        names = self._name.get_qualified_names(include_module_names=True)
+        if names is None:
+            return None
+
+        names = list(names)
+        try:
+            names[0] = self._mapping[names[0]]
+        except KeyError:
+            pass
+
+        return '.'.join(names)

     def is_stub(self):
         """
         Returns True if the current name is defined in a stub file.
         """
-        pass
+        if not self._name.is_value_name:
+            return False
+
+        return self._name.get_root_context().is_stub()

     def is_side_effect(self):
         """
         Checks if a name is defined as ``self.foo = 3``. In case of self, this
         function would return False, for foo it would return True.
         """
-        pass
+        tree_name = self._name.tree_name
+        if tree_name is None:
+            return False
+        return tree_name.is_definition() and tree_name.parent.type == 'trailer'

     @debug.increase_indent_cm('goto on name')
     def goto(self, *, follow_imports=False, follow_builtin_imports=False,
-        only_stubs=False, prefer_stubs=False):
+             only_stubs=False, prefer_stubs=False):
+
         """
         Like :meth:`.Script.goto` (also supports the same params), but does it
         for the current name. This is typically useful if you are using
@@ -305,7 +439,19 @@ class BaseName:
         :param prefer_stubs: Prefer stubs to Python objects for this goto call.
         :rtype: list of :class:`Name`
         """
-        pass
+        if not self._name.is_value_name:
+            return []
+
+        names = self._name.goto()
+        if follow_imports:
+            names = filter_follow_imports(names, follow_builtin_imports)
+        names = convert_names(
+            names,
+            only_stubs=only_stubs,
+            prefer_stubs=prefer_stubs,
+        )
+        return [self if n == self._name else Name(self._inference_state, n)
+                for n in names]

     @debug.increase_indent_cm('infer on name')
     def infer(self, *, only_stubs=False, prefer_stubs=False):
@@ -325,7 +471,23 @@ class BaseName:
             inference call.
         :rtype: list of :class:`Name`
         """
-        pass
+        assert not (only_stubs and prefer_stubs)
+
+        if not self._name.is_value_name:
+            return []
+
+        # First we need to make sure that we have stub names (if possible) that
+        # we can follow. If we don't do that, we can end up with the inferred
+        # results of Python objects instead of stubs.
+        names = convert_names([self._name], prefer_stubs=True)
+        values = convert_values(
+            ValueSet.from_sets(n.infer() for n in names),
+            only_stubs=only_stubs,
+            prefer_stubs=prefer_stubs,
+        )
+        resulting_names = [c.name for c in values]
+        return [self if n == self._name else Name(self._inference_state, n)
+                for n in resulting_names]

     def parent(self):
         """
@@ -333,12 +495,40 @@ class BaseName:

         :rtype: Name
         """
-        pass
+        if not self._name.is_value_name:
+            return None
+
+        if self.type in ('function', 'class', 'param') and self._name.tree_name is not None:
+            # Since the parent_context doesn't really match what the user
+            # thinks of that the parent is here, we do these cases separately.
+            # The reason for this is the following:
+            # - class: Nested classes parent_context is always the
+            #   parent_context of the most outer one.
+            # - function: Functions in classes have the module as
+            #   parent_context.
+            # - param: The parent_context of a param is not its function but
+            #   e.g. the outer class or module.
+            cls_or_func_node = self._name.tree_name.get_definition()
+            parent = search_ancestor(cls_or_func_node, 'funcdef', 'classdef', 'file_input')
+            context = self._get_module_context().create_value(parent).as_context()
+        else:
+            context = self._name.parent_context
+
+        if context is None:
+            return None
+        while context.name is None:
+            # Happens for comprehension contexts
+            context = context.parent_context
+
+        return Name(self._inference_state, context.name)

     def __repr__(self):
-        return '<%s %sname=%r, description=%r>' % (self.__class__.__name__,
-            'full_' if self.full_name else '', self.full_name or self.name,
-            self.description)
+        return "<%s %sname=%r, description=%r>" % (
+            self.__class__.__name__,
+            'full_' if self.full_name else '',
+            self.full_name or self.name,
+            self.description,
+        )

     def get_line_code(self, before=0, after=0):
         """
@@ -350,7 +540,34 @@ class BaseName:
         :return str: Returns the line(s) of code or an empty string if it's a
                      builtin.
         """
-        pass
+        if not self._name.is_value_name:
+            return ''
+
+        lines = self._name.get_root_context().code_lines
+        if lines is None:
+            # Probably a builtin module, just ignore in that case.
+            return ''
+
+        index = self._name.start_pos[0] - 1
+        start_index = max(index - before, 0)
+        return ''.join(lines[start_index:index + after + 1])
+
+    def _get_signatures(self, for_docstring=False):
+        if self._name.api_type == 'property':
+            return []
+        if for_docstring and self._name.api_type == 'statement' and not self.is_stub():
+            # For docstrings we don't resolve signatures if they are simple
+            # statements and not stubs. This is a speed optimization.
+            return []
+
+        if isinstance(self._name, MixedName):
+            # While this would eventually happen anyway, it's basically just a
+            # shortcut to not infer anything tree related, because it's really
+            # not necessary.
+            return self._name.infer_compiled_value().get_signatures()
+
+        names = convert_names([self._name], prefer_stubs=True)
+        return [sig for name in names for sig in name.infer().get_signatures()]

     def get_signatures(self):
         """
@@ -359,7 +576,10 @@ class BaseName:

         :rtype: list of :class:`BaseSignature`
         """
-        pass
+        return [
+            BaseSignature(self._inference_state, s)
+            for s in self._get_signatures()
+        ]

     def execute(self):
         """
@@ -368,7 +588,7 @@ class BaseName:

         :rtype: list of :class:`Name`
         """
-        pass
+        return _values_to_definitions(self._name.infer().execute_with_values())

     def get_type_hint(self):
         """
@@ -380,7 +600,7 @@ class BaseName:

         :rtype: str
         """
-        pass
+        return self._name.infer().get_type_hint()


 class Completion(BaseName):
@@ -388,16 +608,30 @@ class Completion(BaseName):
     ``Completion`` objects are returned from :meth:`.Script.complete`. They
     provide additional information about a completion.
     """
-
     def __init__(self, inference_state, name, stack, like_name_length,
-        is_fuzzy, cached_name=None):
+                 is_fuzzy, cached_name=None):
         super().__init__(inference_state, name)
+
         self._like_name_length = like_name_length
         self._stack = stack
         self._is_fuzzy = is_fuzzy
         self._cached_name = cached_name
+
+        # Completion objects with the same Completion name (which means
+        # duplicate items in the completion)
         self._same_name_completions = []

+    def _complete(self, like_name):
+        append = ''
+        if settings.add_bracket_after_function \
+                and self.type == 'function':
+            append = '('
+
+        name = self._name.get_public_name()
+        if like_name:
+            name = name[self._like_name_length:]
+        return name + append
+
     @property
     def complete(self):
         """
@@ -419,7 +653,9 @@ class Completion(BaseName):
         completing ``foo(par`` would give a ``Completion`` which ``complete``
         would be ``am=``.
         """
-        pass
+        if self._is_fuzzy:
+            return None
+        return self._complete(True)

     @property
     def name_with_symbols(self):
@@ -434,20 +670,58 @@ class Completion(BaseName):
         ``name_with_symbols`` would be "param=".

         """
-        pass
+        return self._complete(False)

     def docstring(self, raw=False, fast=True):
         """
         Documented under :meth:`BaseName.docstring`.
         """
-        pass
+        if self._like_name_length >= 3:
+            # In this case we can just resolve the like name, because we
+            # wouldn't load like > 100 Python modules anymore.
+            fast = False
+
+        return super().docstring(raw=raw, fast=fast)
+
+    def _get_docstring(self):
+        if self._cached_name is not None:
+            return completion_cache.get_docstring(
+                self._cached_name,
+                self._name.get_public_name(),
+                lambda: self._get_cache()
+            )
+        return super()._get_docstring()
+
+    def _get_docstring_signature(self):
+        if self._cached_name is not None:
+            return completion_cache.get_docstring_signature(
+                self._cached_name,
+                self._name.get_public_name(),
+                lambda: self._get_cache()
+            )
+        return super()._get_docstring_signature()
+
+    def _get_cache(self):
+        return (
+            super().type,
+            super()._get_docstring_signature(),
+            super()._get_docstring(),
+        )

     @property
     def type(self):
         """
         Documented under :meth:`BaseName.type`.
         """
-        pass
+        # Purely a speed optimization.
+        if self._cached_name is not None:
+            return completion_cache.get_type(
+                self._cached_name,
+                self._name.get_public_name(),
+                lambda: self._get_cache()
+            )
+
+        return super().type

     def get_completion_prefix_length(self):
         """
@@ -465,7 +739,7 @@ class Completion(BaseName):

         completing ``foo(par`` would return 3.
         """
-        pass
+        return self._like_name_length

     def __repr__(self):
         return '<%s: %s>' % (type(self).__name__, self._name.get_public_name())
@@ -476,7 +750,6 @@ class Name(BaseName):
     *Name* objects are returned from many different APIs including
     :meth:`.Script.goto` or :meth:`.Script.infer`.
     """
-
     def __init__(self, inference_state, definition):
         super().__init__(inference_state, definition)

@@ -487,26 +760,33 @@ class Name(BaseName):

         :rtype: list of :class:`Name`
         """
-        pass
+        defs = self._name.infer()
+        return sorted(
+            unite(defined_names(self._inference_state, d) for d in defs),
+            key=lambda s: s._name.start_pos or (0, 0)
+        )

     def is_definition(self):
         """
         Returns True, if defined as a name in a statement, function or class.
         Returns False, if it's a reference to such a definition.
         """
-        pass
+        if self._name.tree_name is None:
+            return True
+        else:
+            return self._name.tree_name.is_definition()

     def __eq__(self, other):
-        return (self._name.start_pos == other._name.start_pos and self.
-            module_path == other.module_path and self.name == other.name and
-            self._inference_state == other._inference_state)
+        return self._name.start_pos == other._name.start_pos \
+            and self.module_path == other.module_path \
+            and self.name == other.name \
+            and self._inference_state == other._inference_state

     def __ne__(self, other):
         return not self.__eq__(other)

     def __hash__(self):
-        return hash((self._name.start_pos, self.module_path, self.name,
-            self._inference_state))
+        return hash((self._name.start_pos, self.module_path, self.name, self._inference_state))


 class BaseSignature(Name):
@@ -514,7 +794,6 @@ class BaseSignature(Name):
     These signatures are returned by :meth:`BaseName.get_signatures`
     calls.
     """
-
     def __init__(self, inference_state, signature):
         super().__init__(inference_state, signature.name)
         self._signature = signature
@@ -527,7 +806,8 @@ class BaseSignature(Name):

         :rtype: list of :class:`.ParamName`
         """
-        pass
+        return [ParamName(self._inference_state, n)
+                for n in self._signature.get_param_names(resolve_stars=True)]

     def to_string(self):
         """
@@ -536,7 +816,7 @@ class BaseSignature(Name):

         :rtype: str
         """
-        pass
+        return self._signature.to_string()


 class Signature(BaseSignature):
@@ -544,7 +824,6 @@ class Signature(BaseSignature):
     A full signature object is the return value of
     :meth:`.Script.get_signatures`.
     """
-
     def __init__(self, inference_state, signature, call_details):
         super().__init__(inference_state, signature)
         self._call_details = call_details
@@ -558,7 +837,9 @@ class Signature(BaseSignature):

         :rtype: int
         """
-        pass
+        return self._call_details.calculate_index(
+            self._signature.get_param_names(resolve_stars=True)
+        )

     @property
     def bracket_start(self):
@@ -568,22 +849,24 @@ class Signature(BaseSignature):

         :rtype: int, int
         """
-        pass
+        return self._call_details.bracket_leaf.start_pos

     def __repr__(self):
-        return '<%s: index=%r %s>' % (type(self).__name__, self.index, self
-            ._signature.to_string())
+        return '<%s: index=%r %s>' % (
+            type(self).__name__,
+            self.index,
+            self._signature.to_string(),
+        )


 class ParamName(Name):
-
     def infer_default(self):
         """
         Returns default values like the ``1`` of ``def foo(x=1):``.

         :rtype: list of :class:`.Name`
         """
-        pass
+        return _values_to_definitions(self._name.infer_default())

     def infer_annotation(self, **kwargs):
         """
@@ -591,7 +874,7 @@ class ParamName(Name):
             executed and classes are returned instead of instances.
         :rtype: list of :class:`.Name`
         """
-        pass
+        return _values_to_definitions(self._name.infer_annotation(ignore_stars=True, **kwargs))

     def to_string(self):
         """
@@ -600,7 +883,7 @@ class ParamName(Name):

         :rtype: str
         """
-        pass
+        return self._name.to_string()

     @property
     def kind(self):
@@ -609,4 +892,4 @@ class ParamName(Name):

         :rtype: :py:attr:`inspect.Parameter.kind`
         """
-        pass
+        return self._name.get_kind()
diff --git a/jedi/api/completion.py b/jedi/api/completion.py
index 2aa05f9a..342f7506 100644
--- a/jedi/api/completion.py
+++ b/jedi/api/completion.py
@@ -1,10 +1,12 @@
 import re
 from textwrap import dedent
 from inspect import Parameter
+
 from parso.python.token import PythonTokenTypes
 from parso.python import tree
 from parso.tree import search_ancestor, Leaf
 from parso import split_lines
+
 from jedi import debug
 from jedi import settings
 from jedi.api