From c336622516209cd347f74f7cf3b380728ce1270f Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 01:48:46 +0100 Subject: [PATCH 1/7] testing: Switch to Python 3.9 Don't bother with older versions. --- .pre-commit-config.yaml | 28 ++++++++++++++-------------- Makefile | 2 +- tox.ini | 6 +----- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a1ed842..5248878e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: v1.4.0 hooks: - id: autopep8-wrapper - language_version: python2 + language_version: python3 args: - --in-place - --aggressive @@ -11,40 +11,40 @@ repos: - --ignore=E731 - --max-line-length=131 - id: check-added-large-files - language_version: python2 + language_version: python3 - id: check-ast - language_version: python2 + language_version: python3 - id: check-case-conflict - language_version: python2 + language_version: python3 - id: check-docstring-first - language_version: python2 + language_version: python3 - id: debug-statements - language_version: python2 + language_version: python3 - id: double-quote-string-fixer - language_version: python2 + language_version: python3 - id: end-of-file-fixer - language_version: python2 + language_version: python3 exclude_types: [batch, lua] - id: fix-encoding-pragma - language_version: python2 + language_version: python3 - id: flake8 - language_version: python2 + language_version: python3 args: - --max-complexity=10 - --max-line-length=131 - --ignore=E402,E731 - --exclude=bin/autojump_argparse.py - id: name-tests-test - language_version: python2 + language_version: python3 - id: requirements-txt-fixer - language_version: python2 + language_version: python3 - id: trailing-whitespace - language_version: python2 + language_version: python3 - repo: git@github.com:asottile/reorder_python_imports.git rev: v1.1.1 hooks: - id: reorder-python-imports - language_version: python2 + language_version: python3 - repo: git@github.com:asottile/add-trailing-comma rev: v0.7.0 hooks: diff --git a/Makefile b/Makefile index c0c828cf..1ea5cc6b 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ test-xfail: pre-commit .PHONY: test-fast test-fast: pre-commit - @tox -e py27 + @tox -e py39 .PHONY: clean clean: diff --git a/tox.ini b/tox.ini index 8a21b973..8bd4fc65 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,6 @@ [tox] envlist = - py26, - py27, - py33, - py34, - py35 + py39 # ignore missing setup.py skipsdist = True From f6acb90eaec0bc1732b3f3415898706abd735b77 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 02:08:20 +0100 Subject: [PATCH 2/7] travis: Switch to Python 3.9 --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f04fa15c..274bdd09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,9 @@ language: python -python: 2.7 +python: 3.9 env: - - TOX_ENV=py26 - - TOX_ENV=py27 - - TOX_ENV=py32 - - TOX_ENV=py33 - - TOX_ENV=py34 + - TOX_ENV=py39 - TOX_ENV=flake8 install: From 022814c86bf0e6d261ed1a195c0725d681ab8da9 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 01:50:05 +0100 Subject: [PATCH 3/7] tests/unit/autojump_match_test: Fix backslashes in strings --- tests/unit/autojump_match_test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/autojump_match_test.py b/tests/unit/autojump_match_test.py index bd02ff50..3b823911 100644 --- a/tests/unit/autojump_match_test.py +++ b/tests/unit/autojump_match_test.py @@ -19,8 +19,8 @@ class TestMatchAnywhere(object): entry4 = Entry('/中/zhong/国/guo', 10) entry5 = Entry('/is\'t/this/a/b*tchin/edge/case?', 10) win_entry1 = Entry('C:\\foo\\bar\\baz', 10) - win_entry2 = Entry('D:\Program Files (x86)\GIMP', 10) - win_entry3 = Entry('C:\Windows\System32', 10) + win_entry2 = Entry('D:\\Program Files (x86)\\GIMP', 10) + win_entry3 = Entry('C:\\Windows\\System32', 10) @pytest.fixture def haystack(self): @@ -75,9 +75,9 @@ class TestMatchConsecutive(object): entry4 = Entry('/中/zhong/国/guo', 10) entry5 = Entry('/日/本', 10) entry6 = Entry('/is\'t/this/a/b*tchin/edge/case?', 10) - win_entry1 = Entry('C:\Foo\Bar\Baz', 10) - win_entry2 = Entry('D:\Program Files (x86)\GIMP', 10) - win_entry3 = Entry('C:\Windows\System32', 10) + win_entry1 = Entry('C:\\Foo\\Bar\\Baz', 10) + win_entry2 = Entry('D:\\Program Files (x86)\\GIMP', 10) + win_entry3 = Entry('C:\\Windows\\System32', 10) @pytest.fixture def haystack(self): From 5a57837f8bc9c8400dac8d65c43ecfb3304f626b Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 01:50:41 +0100 Subject: [PATCH 4/7] tox: Fix obsoletion warning --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8bd4fc65..ca88e013 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = pytest >= 2.9 commands = coverage run --source=bin/ --omit=bin/autojump_argparse.py -m \ - py.test -vv -rxs --tb native -s --strict {posargs:tests} + py.test -vv -rxs --tb native -s --strict-markers {posargs:tests} coverage report -m From d54a752609af45031943fdcc3684cb4e214b56a3 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 01:52:48 +0100 Subject: [PATCH 5/7] tests/integration: Add a failing test Reproduce https://github.com/wting/autojump/issues/348 --- bin/autojump.py | 1 + tests/integration/autojump_test.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 120000 bin/autojump.py create mode 100644 tests/integration/autojump_test.py diff --git a/bin/autojump.py b/bin/autojump.py new file mode 120000 index 00000000..ee78df49 --- /dev/null +++ b/bin/autojump.py @@ -0,0 +1 @@ +autojump \ No newline at end of file diff --git a/tests/integration/autojump_test.py b/tests/integration/autojump_test.py new file mode 100644 index 00000000..0206ff7f --- /dev/null +++ b/tests/integration/autojump_test.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import os +import sys + +sys.path.append(os.path.join(os.getcwd(), 'bin')) # noqa +from autojump import find_matches +from autojump_data import entriefy + + +def test_find_matches_returns_unique_results(tmpdir): + path = str(tmpdir) + needle = str(os.path.basename(tmpdir)) + + matches = find_matches(entriefy({path: 10}), [needle]) + + assert list(matches) == list(entriefy({path: 10})) From 134d4be938eeffda2d3cda24453f94b113c46163 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 02:05:15 +0100 Subject: [PATCH 6/7] bin/autojump: Fix a Flake8 warning --- bin/autojump | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/autojump b/bin/autojump index ed0151d9..2b2ec38a 100755 --- a/bin/autojump +++ b/bin/autojump @@ -129,8 +129,8 @@ def parse_arguments(): help='show database entries and their key weights', ) parser.add_argument( - '-v', '--version', action='version', version='%(prog)s v' + - VERSION, help='show version information', + '-v', '--version', action='version', version='%(prog)s v' + VERSION, + help='show version information', ) return parser.parse_args() From d9562242c4b12aa4ea7516ef5a2f9483cc8e67fd Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 02:05:39 +0100 Subject: [PATCH 7/7] bin/autojump: Make the test pass Fixes https://github.com/wting/autojump/issues/348 --- bin/autojump | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/autojump b/bin/autojump index 2b2ec38a..52f9d2d0 100755 --- a/bin/autojump +++ b/bin/autojump @@ -196,11 +196,11 @@ def find_matches(entries, needles, check_entries=True): return ifilter( lambda entry: not is_cwd(entry) and path_exists(entry), - chain( + set(chain( match_consecutive(needles, data, ignore_case), match_fuzzy(needles, data, ignore_case), match_anywhere(needles, data, ignore_case), - ), + )), )